Unsolved Qt 5.8 how does Webview do a request and how can I intercept it?
-
I am trying to pass QNetworkRequest to a webView located in my main.qml file instead of a "url". I pass the url by referecing the webView object and the setproperty function. However, haven't found the right function and really do not know where to start in order to either create a new function or modify the existing webView code in order to get this to work. Is there a way to edit the source code to the webView in the .qml file. Of course i am just learning the Qt framework
import QtQuick 2.2 import QtQuick.Controls 1.1 import QtWebView 1.1 import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.2 ApplicationWindow { flags: Qt.FramelessWindowHint visible: true x: 600 y: 400 width: 500 height: 500 title: webView.title WebView { id: webView anchors.fill: parent objectName: "webView" //setting this value through main.cpp // url: "https://www.google.com" onLoadingChanged: { if (loadRequest.errorString) console.error(loadRequest.errorString); } } }
int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QtWebView::initialize(); QQmlApplicationEngine engine; //How to Pass THIS request to the webview instead of url? QNetworkRequest request; request.setUrl(QUrl("http://google.com")); request.setRawHeader("Accept-Charset", "UTF-8,*;q=0.5"); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QObject *rootObject = engine.rootObjects().first(); QObject *qmlObject = rootObject->findChild<QObject*>("webView"); //Able to set the URL for the webView: qmlObject->setProperty("url", "https://www.google.com" ); return app.exec(); }
-
I have tried WebengineView but the Webview is MUCH faster in loading a page. and that is critical for the application
-
@wrightpt I guess the real question is how does webview do a request and how can i intercept it?