[SOLVED] How to set up proxy for a webview in QML



  • Hi,

    I encouter an issue where I am not able to set up a proxy for awebview inside a QML description file.

    I find this example using QQmlNetworkAccessManagerFactory in examples/qml/networkaccessmanagerfactory
    The proxy works for an image on the net, but when the webView is launched, nothing is displayed.
    Here is my qml file
    @import QtQuick 2.0
    import QtWebKit 3.0

    Rectangle {
    width: 800
    height: 480
    Image {
    width: 100
    height: 100
    source: "http://qt.digia.com/Documents/Qt_master_logo_CMYK_noback.gif"
    }
    WebView {
    id: web_view1
    x: 0
    y: 0
    width: 800
    height: 480
    url: "http://www.google.fr"
    }
    }@

    I know that the webView use webkit2 and therefore launch a new process.
    I was thinking that setting the proxy in the main application will also initialize proxy parameters to the QtWebProcess.

    From what I experienced, the main application that manage the QML view has proxy, but the new process launch for webkit2 does not.

    Does someone know how to set up proxy so that the webview object used it and can be connected to the net ?

    Thanks in advance for all help.

    Regards,
    Yannick



  • I am also facing the same problem, webview in QML is unable to access http. It does not throw any error I just get a blank page.

    When I run Youtube and flicker example only the thumbnail part which is retrieved as XML is displayed but the main page (where the webpage should be displayed) renders nothing.

    I can run fancy browser example without any problem which uses webview QWidget.

    I would appreciate any help.



  • Update...

    I embedded my webview in GUI and now it is loading pages.
    It looks like If I run a plain QML application webview can't access (or load) http. Not sure if I should log this as bug?

    Thanks



  • bq.
    bq. please could you explain me what you call "embedded my webview in GUI" ?
    bq.Does it mean that you use WebkitWidget the C++ object directly, and you
    bq.don't use the QML interface ?
    bq.Thanks in advance for your explanation ?

    Yes Loaded the QML in QWebView. Also when I investigated this problem further I found that if you run the QML in qmlscene viewer it works as expected.

    I suspect when we run QML directly from QTCreator it fails to start the QTWebkit widget or webprocess.exe or both.

    I hope this will help. If this solve your problem please marked solved.



  • I finally solved this issue by setting the environment variable http_proxy. I did not tell you that I was under Linux on a small ARM board.

    Previoulsy, using QT4.8, I needed to set up the proxy using the class QNetworkProxy. I focus to find a similar mechanism on QT5, and I never try this simple solution : setting the environment variable.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.