0

我想要 QWebPage 来加载 html 页面(因为我在控制台应用程序中并且我不能使用 QWebView)。

当我这样做时:

bool webview::load(Arguments *args)
{
    QRegularExpression url("^(file|http)://");
    QRegularExpression fullPath("^/");

    QRegularExpressionMatch pathMatch = fullPath.match(args->getSource());
    QRegularExpressionMatch urlMatch = url.match(args->getSource());

    frame =  navigateur->mainFrame();
    if(pathMatch.hasMatch()) {
        frame->load(QUrl::fromLocalFile(args->getSource()));
    } else {
        if (urlMatch.hasMatch()) {
            frame->load(QUrl(args->getSource()));
        } else {
            fprintf(stderr, "%s\n", qPrintable(QCoreApplication::translate("main", "Error: Invalide source file")));
            return false;
        }
    }
    return true;
}

我有这个错误:

/home/morgan/htmltopdf/webview.cpp:28: error: invalid use of incomplete type 'class QWebFrame'
         frame->load(QUrl::fromLocalFile(args->getSource()));
              ^
4

1 回答 1

2

您需要,这里缺少#include <QWebFrame>的定义。QWebFrame

于 2014-08-04T10:38:02.243 回答