2012-07-10 46 views
0
#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,它会说试图让Qt4例子在安装了Qt Creator 4的Ubuntu 10.10上运行

/home/me/qtwebkit-examples-and-demos/examples/webkit/framecapture-build-desktop/../framecapture/main.cpp:68: error: variable ‘QApplication a’ has initializer but incomplete type

/home/me/qtwebkit-examples-and-demos/examples/webkit/framecapture-build-desktop/../framecapture/main.cpp:70: error: incomplete type ‘QApplication’ used in nested name specifier

我不知道为什么没有从git的例子://gitorious.org/+qt-developers/qt/qtwebkit-examples-and-demos- staging.git正在工作。它似乎总是抱怨#包含找不到所需的组件。

回答

1

您将只需包含QApplication。那就是:

#include <QApplication> 

如果我没有记错的话有没有这样的包括文件<QtWidget>反正。那应该是<QWidget>。鉴于具体的例子,我预计一般包括<QtGui>

+0

这工作,但我很好奇他们为什么仍然使用QtWidget,并没有打扰包括QApplication。他们是否可以使用旧版Qt?谢谢!! – KJW 2012-07-10 08:45:05

+0

正如我的预期(并在我的回答中指出),该文件实际上包含''而不是'',正如您在上面的答案中所述。 (我已经从刚刚链接的git中获得了源代码)。所以他们最近改变了它或者你编辑了它。包括QtGui将包括所有相关的文件,所以应该工作得很好。 – Bart 2012-07-10 08:50:58