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 !