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 を使用すると、

/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の例がどれも機能していない理由がわかりません。#includes が必要なコンポーネントを見つけられないことについて常に不平を言っているようです。

4

1 に答える 1

1

You will simply have to include QApplication. That is:

#include <QApplication>

If I'm not mistaken there is no such include file as <QtWidget> anyway. That should be <QWidget>. Given the specific example I would expect a general include of <QtGui> instead.

于 2012-07-10T08:36:01.087 に答える