Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OSM QML map embedded in widget

OSM QML map embedded in widget

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    seb21
    wrote on last edited by
    #1

    Hi,
    I try to make a QML map embedded in a widget.
    Here is my code:

    QQuickWidget* widget = new QQuickWidget();
    widget->setSource(QUrl(QStringLiteral("qmlMain.qml")));
    ui.gridLayout->addWidget(widget);
    

    gridLayout was added in the QtDesigner

    and for the QML part :

    import QtQuick 2.0
    import QtQuick.Window 2.0
    import QtLocation 5.6
    import QtPositioning 5.6
    
    Item {
        id: qmlMap
    
        Plugin {
            id: osmPlugin
            name: "osm"
        }
    
        Map {
            anchors.fill: parent
            plugin: osmPlugin
            center: QtPositioning.coordinate(59.91, 10.75) // Oslo
            zoomLevel: 10
        }
    }
    

    But all I can see is a blank widget 0_1503566828537_Untitled-1.jpg

    This work perfectly in a QML application, and if the QML file doesn't contain a map (label, buttons etc...)

    I am using VC2017 and I have correctly added QtLocation and QtPosition libs in the project.

    What am I missing ?

    thx

    raven-worxR 1 Reply Last reply
    0
    • S seb21

      Hi,
      I try to make a QML map embedded in a widget.
      Here is my code:

      QQuickWidget* widget = new QQuickWidget();
      widget->setSource(QUrl(QStringLiteral("qmlMain.qml")));
      ui.gridLayout->addWidget(widget);
      

      gridLayout was added in the QtDesigner

      and for the QML part :

      import QtQuick 2.0
      import QtQuick.Window 2.0
      import QtLocation 5.6
      import QtPositioning 5.6
      
      Item {
          id: qmlMap
      
          Plugin {
              id: osmPlugin
              name: "osm"
          }
      
          Map {
              anchors.fill: parent
              plugin: osmPlugin
              center: QtPositioning.coordinate(59.91, 10.75) // Oslo
              zoomLevel: 10
          }
      }
      

      But all I can see is a blank widget 0_1503566828537_Untitled-1.jpg

      This work perfectly in a QML application, and if the QML file doesn't contain a map (label, buttons etc...)

      I am using VC2017 and I have correctly added QtLocation and QtPosition libs in the project.

      What am I missing ?

      thx

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @seb21 said in OSM QML map embedded in widget:

      QQuickWidget* widget = new QQuickWidget();
      widget->setSource(QUrl(QStringLiteral("qmlMain.qml")));
      widget->setResizeMode( QQuickWidget::SizeRootObjectToView );
      ui.gridLayout->addWidget(widget);
      

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • S Offline
        S Offline
        seb21
        wrote on last edited by
        #3

        damn ! thx a lot

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved