1

being trying to solve issue for a long time, no success, QT version 5.15.0. MinGW 8.1.0, 64 bit

The issue seems to happen only when loading the map plugin in the QML file, below is a snip it of the code The call qmlView->setSource(QUrl("qrc:/maps/map.qml")); waits at least 2 seconds and the GUI then freeze. Basically the GUI thread is blocked for 2 seconds. I tried to call qmlView->setSource(QUrl("qrc:/maps/map.qml")) in a separate thread but crashed, Not too sure if the Loader QML Type would work, becasue its the same GUI thread.

I even tried the example for https://doc.qt.io/qt-5/qtlocation-mapviewer-example.html, when you change provider the main GUI also freezes

Is there any way to load the QML files where the GUI does not freeze? Thanks

    QQuickView * qmlView = new QQuickView();
    QQmlEngine * eng = qmlView->engine();
    eng->addPluginPath(qApp->applicationDirPath());
    qmlView->setSource(QUrl("qrc:/maps/map.qml"));

The QML file is

import QtQuick 2.0
import QtQuick.Window 2.0
import QtLocation 5.15
import QtPositioning 5.6


Item {
    id: item
    anchors.fill: parent

    visible: true


    Plugin {
        id: mapPlugin
        name: "osm"  // Other mapas are "osm", "mapbox"  "mapboxgl", "esri", ...
    }
    Map {
        id: map
        anchors.fill: parent
        anchors.leftMargin: -84
        anchors.topMargin: -47

        objectName: "rect"



        plugin: mapPlugin
        center {
            latitude: 52.1619403
            longitude: -7.1488692
        }
        zoomLevel: 14

    }

}


After the input from JarMan, I tried to use the QML Loader, see below, but the GUI still freezes

Loader {
    id: windowLoader
    source: "qrc:/maps/map.qml"
    focus: true
    asynchronous: true

    //property bool valid: item !== null
}
Gerald
  • 23
  • 2
  • Loader has an `asynchronous` property. Does that help? – JarMan Oct 13 '20 at 20:49
  • thanks, I read that, but I presume the same GUI thread will still freeze. I will give it a try, thanks – Gerald Oct 13 '20 at 20:52
  • It should not freeze. The UI is allowed to continue while the loading is taking place. – JarMan Oct 13 '20 at 20:54
  • It does, and I believe Its something to do with the mapPlugin, for example 'esri' freeze less time that using "osm". OSM freezes about 2 seconds and esri freezes about 1 second. It looks like its getting the map data but blocking the main gui thread. – Gerald Oct 13 '20 at 20:57
  • Just tried Loader { id: windowLoader source: "qrc:/maps/map.qml" focus: true asynchronous: true //property bool valid: item !== null } – Gerald Oct 14 '20 at 08:32
  • Does any know if this is a feature or a bug? thanks – Gerald Oct 18 '20 at 15:15
  • @Gerald, Have you found an answer to your question? – Saeed Masoomi Nov 03 '22 at 15:51

0 Answers0