0

Im working on a management project in which i gotta manage clients data from a database , and i have to add a map widget which shows a client's position (by fetching his coordinates from the database) .. i created a little prototype to learn how to use QML + Map Plugin because i never used them before , and i decided to use QQuickWidget to show my Map (the Map's QML was taken from Qt's examples with a few modifications) .. but im facing an issue , when i execute my program , it takes minutes to show the UI , which i assumed is related to my slow internet connection to fetch the map's data and all , but what i need here is to show the UI and eveything (execute database queries and all). So what i need is to execute the Map's widget (fetch the map) WHILE processing the UI normally so the user can select , search , delete and do whatever he wants (the map's widget would be empty because it hasnt been loaded yet) , UNTIL the map is ready to show.

Here my code: MainWindow:

ui->quickWidget->setSource(QUrl("qrc:/new/prefix1/main.qml"));
QObject *object = ui->quickWidget->rootObject();
object->setProperty("_title" , "Oslo");
object->setProperty("_x" , "59.93");
object->setProperty("_y" , "10.76"); 

Map's QML Script (main.qml):

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

Item
{
    width: 512
    height: 512
    visible: true
    property var _x: 0
    property var _y: 0
    property string _title: ""

    Plugin
    {
        id: mapPlugin
        name: "osm"
    }

    Map
    {
        anchors.fill: parent
        plugin: mapPlugin
        center: QtPositioning.coordinate(_x , _y)
        zoomLevel: 15

        ListModel
        {
            id: locationModel
            ListElement {lat: 0; lon: 0; color: "blue"}
            ListElement {lat: 5; lon: 12.5; color: "green"}
            ListElement {lat: 10; lon: 25; color: "red"}
        }

        MapItemView
        {
            model: locationModel
            delegate: MapQuickItem
            {
                coordinate: QtPositioning.coordinate(_x , _y)
                anchorPoint: Qt.point(10 , 10)
                sourceItem: Column
                {
                    Image {source: "marker.png"}
                    Text {text: _title}
                }
            }
        }
    }
}

Thank you !

RedZ
  • 857
  • 1
  • 13
  • 25
  • http://doc.qt.io/qt-5/qml-qtquick-loader.html consider async mode loader. I could not answer because of `center` property of the map that needs to be set somehow but generally loaders can do it. For passing parameters consider Method 2 from answer here: https://stackoverflow.com/questions/44271158/pass-properties-to-object-created-by-qml-loader – Alexander V Sep 26 '18 at 04:00
  • I ended up using Leafet's Javascript Map API with a QWebEngineView to load , view , and set the center without freezing the UI – RedZ Sep 26 '18 at 10:12
  • I did see loading of the MAP is QML async without all that extra. – Alexander V Sep 26 '18 at 14:40

1 Answers1

0

I've figured out that problem is caused by absence of OpenSSL libraries. You can read related topic here:

Solution, that works for me:

  • download .zip file from https://indy.fulgan.com/SSL/
  • extract libeay32.dll and ssleay32.dll
  • copy them to qt binary folder (for example in my case \QT\Qt5.11.0\5.11.0\mingw53_32\bin\ )
RedApe
  • 119
  • 1
  • 6