Results 1 to 17 of 17

Thread: Embedded Map in QWidget c++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2016
    Posts
    16
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Embedded Map in QWidget c++

    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:

    Qt Code:
    1. QQmlEngine *engine = new QQmlEngine(this);
    2. QQuickWidget *view = new QQuickWidget(engine, this);
    3. view->setSource(QUrl("qrc:/test.qml"));
    4. 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".
    Qt Code:
    1. import QtQuick 2.0
    2. import QtLocation 5.3
    3.  
    4. Plugin {
    5. name: "osm"
    6. PluginParameter { name: "osm.useragent"; value "MapViewer"}
    7. PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" }
    8. PluginParameter { name: "osm.mapping.copyright"; value: "All mine" }
    9. PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" }
    10. PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" }
    11. }
    12.  
    13. Map {
    14. id: map
    15.  
    16. plugin: osm
    17.  
    18. zoomLevel: map.minimumZoomLevel
    19.  
    20. center {
    21. // The Qt Company in Oslo
    22. latitude: 59.9485
    23. longitude: 10.7686
    24. }
    25. }
    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!!!!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Embedded Map in QWidget c++

    A QML file has one and only one top level element, yours has two.

    Cheers,
    _

    P.S.: if you are looking for a widget based map view, look here https://inqlude.org/libraries/marble.html

  3. The following user says thank you to anda_skoa for this useful post:

    froeben (15th February 2016)

Similar Threads

  1. Replies: 2
    Last Post: 16th April 2013, 17:49
  2. Replies: 1
    Last Post: 16th September 2010, 15:57
  3. Multiple apps using Qt/Embedded+Qtopia on Embedded Linux
    By drahardja in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 17th February 2008, 21:46
  4. Replies: 1
    Last Post: 2nd May 2006, 21:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.