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