c++ - 使用 QWebPage 加载页面

标签 c++ qt5.3

我想要 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()));
              ^

最佳答案

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

关于c++ - 使用 QWebPage 加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25116761/

相关文章:

c++ - 应用程序段错误,仅当使用 MinGW 在 Windows 上编译时

c++使用stringstream从字符串中提取一个int

c++ - 在 QT QTextEdit 中粘贴表情符号

c++ - qt 如何使用按钮动态添加包含一些小部件的组框?

c++ - QtConcurrent 在 reportResultsReady 上崩溃

c++ - 沿对角线编程 0

c++ - 在 OpenGL 中自由类型文本后面的渲染正方形被裁剪

c++ - 如何在 Eclipse 中设置文档片段?

c++ - Qt 资源系统中文件的最后修改日期