Hi Community,
i would like to embed an QML-Map into a widget.
From general: i have successfully embedded a text (QML) with the following code:
QQmlEngine *engine = new QQmlEngine(this);
QQuickWidget *view = new QQuickWidget(engine, this);
view
->setSource
(QUrl("qrc:/test.qml"));
this->setCentralWidget(view);
QQmlEngine *engine = new QQmlEngine(this);
QQuickWidget *view = new QQuickWidget(engine, this);
view->setSource(QUrl("qrc:/test.qml"));
this->setCentralWidget(view);
To copy to clipboard, switch view to plain text mode
test.qml is taken from an example.
Embedding the following Map.qml does yield to syntax error at line 13. I doubt the reason is that i don't have a "parent".
import QtQuick 2.0
import QtLocation 5.3
Plugin {
name: "osm"
PluginParameter { name: "osm.useragent"; value "MapViewer"}
PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" }
PluginParameter { name: "osm.mapping.copyright"; value: "All mine" }
PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" }
PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" }
}
Map {
id: map
plugin: osm
zoomLevel: map.minimumZoomLevel
center {
// The Qt Company in Oslo
latitude: 59.9485
longitude: 10.7686
}
}
import QtQuick 2.0
import QtLocation 5.3
Plugin {
name: "osm"
PluginParameter { name: "osm.useragent"; value "MapViewer"}
PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" }
PluginParameter { name: "osm.mapping.copyright"; value: "All mine" }
PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" }
PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" }
}
Map {
id: map
plugin: osm
zoomLevel: map.minimumZoomLevel
center {
// The Qt Company in Oslo
latitude: 59.9485
longitude: 10.7686
}
}
To copy to clipboard, switch view to plain text mode
The code shall be embedded in a qwidget because it is part of an existing library that is loaded into a main application.
Could someone give me a hint where i can find a good example? The mapviewer example vom QT-documentation does not hold enough background information how to create a qwidget holding a QML-Map.
Thx!!!!
Bookmarks