#include "framecapture.h"
#include <iostream>
#include <QtWidget>
int main(int argc, char * argv[])
{
if (argc != 3) {
std::cout << "Capture a web page and save its internal frames in different images" << std::endl << std::endl;
std::cout << " framecapture <url> <outputfile>" << std::endl;
std::cout << std::endl;
std::cout << "Notes:" << std::endl;
std::cout << " 'url' is the URL of the web page to be captured" << std::endl;
std::cout << " 'outputfile' is the prefix of the image files to be generated" << std::endl;
std::cout << std::endl;
std::cout << "Example: " << std::endl;
std::cout << " framecapture qt.nokia.com trolltech.png" << std::endl;
std::cout << std::endl;
std::cout << "Result:" << std::endl;
std::cout << " trolltech.png (full page)" << std::endl;
std::cout << " trolltech_frame1.png (...) trolltech_frameN.png ('N' number of internal frames)" << std::endl;
return 0;
}
QUrl url = QUrl::fromUserInput(QString::fromLatin1(argv[1]));
QString fileName = QString::fromLatin1(argv[2]);
QApplication a(argc, argv);
FrameCapture capture;
QObject::connect(&capture, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
capture.load(url, fileName);
return a.exec();
}
我得到QtWidget文件或目录找不到。当我使用QWidget时,会说
/home/me/qtwebkit-examples-and-demos/examples/webkit/framecapture-build-desktop/../framecapture/main.cpp:68:
错误:变量“ QApplication a”具有初始化程序,但类型不完整
/home/me/qtwebkit-examples-and-demos/examples/webkit/framecapture-build-desktop/../framecapture/main.cpp:70:
错误:嵌套名称说明符中使用了不完整的类型“ QApplication”
我不知道为什么git://gitorious.org/+qt-developers/qt/qtwebkit-examples-and-demos-staging.git中的所有示例都不起作用。似乎总是抱怨#include找不到所需的组件。
最佳答案
您只需要包括QApplication。那是:
#include <QApplication>
如果我没记错的话,就没有
<QtWidget>
这样的包含文件。那应该是<QWidget>
。给定特定的示例,我希望可以改为包含<QtGui>
。关于c++ - 试图让Qt4示例在安装了Qt Creator 4的ubuntu 10.10上运行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11409446/