I assume you men a geogrpahical map, as QMap is something else entirely. 
 
It is trivial to interop between C++ and QML. Depending on how you do it, you can just set a context property  as a QObject-derived class in the C++ API. Otherwise you have to use it as a MetaType.
 
http://doc.qt.io/qt-5/qtqml-cppintegration-data.html
http://doc.qt.io/qt-5/qtqml-cppintegration-definetypes.html <- this is probably waht you want
 
Sent: Sunday, August 14, 2016 at 7:12 AM
From: "Kishore J" <kitts.mailingli...@gmail.com>
To: interest@qt-project.org
Subject: [Interest] Passing QML mapobjects (MapCircle) to QML maps through C++
Hi,
 
Due to the lack of C++ API for maps, i am forced to use QML for the map but i am unable to understand how i need to structure my application.
 
Architecturally, I have a qobject pool and various applications register objects to the pool. Any part of the application that can use the pooled object use it.
 
In this scenario, i have some plugins that would pass map objects (or map object factories) to the pool. Then i have one or more maps that take the registered map object and show it on it's map.
 
Since maps only work in QML, it is not clear to me how to achieve this. I have successfully created a MapWidget which basically inherits QQuickWidget along with a qml file that contains the following code.
 
/**************************/
import QtQuick 2.5
import QtLocation 5.6
 
Map {
    id: map
    zoomLevel: (maximumZoomLevel - minimumZoomLevel)/2
 
    plugin: Plugin {
        name: "here"
        PluginParameter { name: "here.app_id"; value: "xxxxx" }
        PluginParameter { name: "here.token"; value: "xxxxx" }
    }
    activeMapType: supportedMapTypes[3]
 
    MapCircle {
        id: circle
        center {
            latitude: 10
            longitude: 20
        }
        radius: 500.0
        color: 'black'
        opacity: .5
        border.width: 1
    }
 
    Component.onCompleted:{
        for(var i = 0; i < supportedMapTypes.length; ++i)
            console.debug(i + ' ' + supportedMapTypes[i].name);
    }
}
/**************************/
 
As such I have almost no experience with QML and getting the above QML file to work was a task in itself for me. I am comfortable with C++ side of things.
 
I would really appreciate it if someone could hand hold me here. I understand that every MapObject that is created would need QML code again but I think i can deal with that. The map objects need not always be circles and could possibly be more complex qml code.
--
Regards,
Kishore
 
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to