From: "Kishore J" <kitts.mailingli...@gmail.com>
To: interest@qt-project.org
Subject: Re: [Interest] Passing QML mapobjects (MapCircle) to QML maps through C++
On 15-Aug-2016 8:47 PM, "Jason H" <jh...@gmx.com> wrote:
>
> I assume you men a geogrpahical map, as QMap is something else entirely.
Yes. I was talking of geographical map.
> 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
Perhaps my problem raises from my lack of understanding of qml language and my mind working with pointers, references. Basically c/c++ like code.
What I can't figure out here is how does one part of c++ code create a mapitem object in qml; get a pointer to it in c++ which in turn passes that object to a geographical map inside another qml file. And then have the map display the mapitem as defined in the former qml file.
I know I'm asking here to do my homework! But I'm really trying to understand how things work in the qml world. It took me several tries before I understood that I had to put that debug statement inside the oncompleted function for it to work. I still don't know how to dynamically change the plugin of the map (from c++) as I would like to have that choice made in a qwidget. I'm still learning...
> 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