からhtmlを取得する必要がありますQWebEnginePage
。ドキュメントでtoHtmlメソッドを見つけましたが、常に空の文字列を返します。toPlainTextを試してみましたが、うまくいきまし
たが、これは私が必要としているものではありません。
MyClass::MyClass(QObject *parent) : QObject(parent)
{
_wp = new QWebEnginePage();
_wp->settings()->setAttribute(QWebEngineSettings::AutoLoadImages, false);
_wp->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
connect(_wp, SIGNAL(loadFinished(bool)), this, SLOT(wpLoadFinished(bool)));
}
void MyClass::start()
{
_wp->load(QUrl("http://google.com/"));
}
void MyClass::wpLoadFinished(bool s)
{
_wp->toHtml(
[] (const QString &result) {
qDebug()<<"html:";
qDebug()<<result;
}); // return empty string
/*_wp->toPlainText(
[] (const QString &result) {
qDebug()<<"txt:";
qDebug()<<result;
});*/ //works perfectly
}
私は何を間違っていますか?