2012-07-10 2 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 파일 또는 디렉토리를 찾을 수 없습니다. //gitorious.org/+qt-developers/qt/qtwebkit-examples-and-demos- : 내가는 QWidget을 사용하는 경우, 그것은Qt Creator 4가 설치된 우분투 10.10에서 Qt4 예제를 실행하려고 시도했습니다.

/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

내가 왜 자식의 예 아무도 모르는 말할 것이다 staging.git이 작동합니다. # 항상 필요한 구성 요소를 찾지 못하는 것에 대해 불평하는 것 같습니다.

답변

1

QApplication을 포함하기 만하면됩니다. 즉 :

#include <QApplication> 

내가 잘못 본게 아니라면 그런 어쨌든 <QtWidget> 같은 파일을 포함하지 있습니다. 그것은 <QWidget>이어야합니다. 구체적인 예를 들자면, 대신에 <QtGui>의 일반 포함을 기대할 수 있습니다.

+0

이 작업을했지만 여전히 QtWidget을 사용하고 QApplication을 포함하지 않는 이유에 대해 골량입니다. Qt의 이전 버전을 사용하고있을 수 있습니까? 고맙습니다!! – KJW

+0

예상대로 (내 답변에 명시된 바와 같이) 위의 대답에서와 같이 파일에 실제로는 ''이 포함되고 ''이 아닌 파일이 포함됩니다. (나는 지금 당신이 연결 한 자식으로부터 소스를 얻었습니다.) 그래서 그들은 최근에 그것을 변경했거나 편집했습니다. QtGui 포함 모든 관련 파일을 포함하므로 잘 작동합니다. – Bart

관련 문제