Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt 5.8 how does Webview do a request and how can I intercept it?
Forum Updated to NodeBB v4.3 + New Features

Qt 5.8 how does Webview do a request and how can I intercept it?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 1 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wrightpt
    wrote on last edited by A Former User
    #1

    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();
            }
    
    1 Reply Last reply
    0
    • W Offline
      W Offline
      wrightpt
      wrote on last edited by
      #2

      I have tried WebengineView but the Webview is MUCH faster in loading a page. and that is critical for the application

      W 1 Reply Last reply
      0
      • W wrightpt

        I have tried WebengineView but the Webview is MUCH faster in loading a page. and that is critical for the application

        W Offline
        W Offline
        wrightpt
        wrote on last edited by
        #3

        @wrightpt I guess the real question is how does webview do a request and how can i intercept it?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved