Using XMLHttpRequest in QML when behind a proxy



  • Does anybody know how to set a proxy for use when using Qt Quick/Qt Creator 4.7 Beta II on Windows 7 system?

    Thanks



  • It seems that the simple way to do this is by hosting your qml file in a C++ app. See C:\Qt\4.7.0-beta2\examples\declarative\cppextensions\networkaccessmanagerfactory as an example.

    You essentially create your own QNetworkAccessManager object and set the proxy on that before creating the QDeclarativeView and calling view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory);



  • If you are using qmlviewer to run your QML, you should be able to set a proxy via "Settings->HTTP Proxy"

    Regards,
    Michael



  • There is a special factory QDeclarativeNetworkAccessManagerFactory to create a network access manager that should be used when accessing the network from QML. The manager created is then made known to the declarative engine by QDeclarativeEngine::setNetworkAccessManagerFactory(), as PixelQ stated already.


Log in to reply
 

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