gpt4 book ai didi

c++ - 使用 QWebPage 加载页面

转载 作者:行者123 更新时间:2023-11-28 02:43:35 25 4
gpt4 key购买 nike

我想要 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com