⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

How to enable QNetworkProxy for a Map plugin?

  • I've got an app that uses local network to talk to some devices, and an http proxy to fetch anything external. I'd like to use the map plugin in it. Now the map would require an http proxy to download the tiles. If I set global Qt proxy settings using http_proxy variable, or do it manually using QNetworkProxy::setApplicationProxy then the map is loading fine, but the rest of the program breaks. If I disable the proxy then I can talk to my devices, but I can't see the map. I've tried using QQmlNetworkAccessManagerFactory, as described in the example here, and it works fine for an Image type object, as defined in the view.qml, but it doesn't work if I replace the Image with an Item that contains my map.

    	width: 500
    	height: 500
    	Plugin {
    		id: mapPlugin
    		name: "osm"
    	Map {
    		anchors.fill: parent
    		plugin: mapPlugin
    		center: QtPositioning.coordinate(59.91, 10.75)
    		zoomLevel: 14
    		visible: true

    The MyNetworkAccessManagerFactory::create method never gets called, and I get the following error:
    QGeoTileRequestManager: Failed to fetch tile (17366,9541,15) 5 times, giving up. Last error message was: 'Error transferring http://c.tile.openstreetmap.org/15/17366/9541.png - server replied: Service Unavailable'.
    What could be the cause of that?

Log in to reply