Yeah sure, couldn't find the edit button, if there is any. so I'll post it here instead of editing main post
#include <QApplication>
#include <QWebEngineView>
#include <iostream>
using namespace std;
class Webkit: public QWebEngineView{
public:
Webkit() {
connect(this->page(), &QWebEnginePage::loadFinished, this, &Webkit::onFinishedLoading);
}
public slots:
void onFinishedLoading(bool ok);
};
void Webkit::onFinishedLoading(bool ok){
this
->page
()->runJavaScript
("document.body;",
[](const QVariant &v
) { cout <<
"JS Result:" << v.
toString().
toStdString() << endl;
});
}
int main(int argc, char *argv[])
{
Webkit kit;
kit.show();
kit.
setUrl(QUrl("http://google.com"));
return app.exec();
}
#include <QApplication>
#include <QWebEngineView>
#include <iostream>
using namespace std;
class Webkit: public QWebEngineView{
public:
Webkit() {
connect(this->page(), &QWebEnginePage::loadFinished, this, &Webkit::onFinishedLoading);
}
public slots:
void onFinishedLoading(bool ok);
};
void Webkit::onFinishedLoading(bool ok){
this->page()->runJavaScript("document.body;", [](const QVariant &v) { cout << "JS Result:" << v.toString().toStdString() << endl; });
}
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
Webkit kit;
kit.show();
kit.setUrl(QUrl("http://google.com"));
return app.exec();
}
To copy to clipboard, switch view to plain text mode
One would expect the following code to have some output on the JS result, however it's empty. (Qt 5.8)
Bookmarks