Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Map not working
Qt 6.11 is out! See what's new in the release blog

Map not working

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
15 Posts 3 Posters 2.8k Views 3 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #3

    The application compiles, but the map does not appear. But it is an example of "places_map" compiles and the map is working.

    1 Reply Last reply
    0
    • M Mikeeeeee

      Hi!
      Map QML not working.
      My ui.qml:

      import QtQuick 2.12
      import QtQml 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.12
      import QtPositioning 5.12
      import QtLocation 5.12
      
      Item {
          width: 400
          height: 650
          visible: true
      
          Plugin {
              id: mapPlugin
              name: "osm" // "mapboxgl", "esri", ...
              // specify plugin parameters if necessary
              // PluginParameter {
              //     name:
              //     value:
              // }
          }
      
          Map {
              anchors.fill: parent
              plugin: mapPlugin
              center: QtPositioning.coordinate(59.91, 10.75) // Oslo
              zoomLevel: 14
          }
      }
      

      I get error: center: QtPositioning.coordinate(59.91, 10.75) - Line 26: Function not supported in a Qt Quick UI form. (M222)

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by JKSH
      #4

      @Mikeeeeee said in Map not working:

      Function not supported in a Qt Quick UI form. (M222)

      QtPositioning.coordinate() is not supported in a *.ui.qml file.

      The example uses a *.qml file, not a *.ui.qml file: https://doc.qt.io/qt-5/qtlocation-minimal-map-example.html

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #5

        Put it in a new file .qml, but the map did not appear, only the white screen.

        import QtQuick 2.12
        import QtQml 2.12
        import QtQuick.Window 2.12
        import QtQuick.Controls 2.12
        import QtPositioning 5.12
        import QtLocation 5.12
        
        Item {
            width: 400
            height: 650
            visible: true
        
            Plugin {
                id: mapPlugin
                name: "osm" // "mapboxgl", "esri", ...
                // specify plugin parameters if necessary
                // PluginParameter {
                //     name:
                //     value:
                // }
            }
        
            Map {
                anchors.fill: parent
                plugin: mapPlugin
                center: QtPositioning.coordinate(59.91, 10.75) // Oslo
                zoomLevel: 14
        
                Text {
                    id: element
                    x: 103
                    y: 51
                    width: 180
                    height: 75
                    text: qsTr("Page with my map")
                    font.pixelSize: 20
                }
            }
        }
        
        sierdzioS 1 Reply Last reply
        0
        • M Mikeeeeee

          Put it in a new file .qml, but the map did not appear, only the white screen.

          import QtQuick 2.12
          import QtQml 2.12
          import QtQuick.Window 2.12
          import QtQuick.Controls 2.12
          import QtPositioning 5.12
          import QtLocation 5.12
          
          Item {
              width: 400
              height: 650
              visible: true
          
              Plugin {
                  id: mapPlugin
                  name: "osm" // "mapboxgl", "esri", ...
                  // specify plugin parameters if necessary
                  // PluginParameter {
                  //     name:
                  //     value:
                  // }
              }
          
              Map {
                  anchors.fill: parent
                  plugin: mapPlugin
                  center: QtPositioning.coordinate(59.91, 10.75) // Oslo
                  zoomLevel: 14
          
                  Text {
                      id: element
                      x: 103
                      y: 51
                      width: 180
                      height: 75
                      text: qsTr("Page with my map")
                      font.pixelSize: 20
                  }
              }
          }
          
          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #6

          I have just tried your code and it works for me.

          I just had to change Item to Window as my main component, because I don't use QQuickView (chances are you are not using it either).

          (Z(:^

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mikeeeeee
            wrote on last edited by
            #7

            From this code I go to the qml-file with the map:

            import QtQuick 2.12
            import QtQml 2.12
            import QtQuick.Window 2.12
            import QtQuick.Controls 2.12
            import QtPositioning 5.12
            import QtLocation 5.12
            
            Window {
                visible: true
                width: 400
                height: 650
                title: qsTr("Name app")
            
                Loader
                          {
                              id: loader
                              anchors.fill: parent
                              //source: "Map.qml"
                              source: "QtMap.qml"
                          }
            }
            

            Where and how to add QQuickView ?

            sierdzioS 1 Reply Last reply
            0
            • M Mikeeeeee

              From this code I go to the qml-file with the map:

              import QtQuick 2.12
              import QtQml 2.12
              import QtQuick.Window 2.12
              import QtQuick.Controls 2.12
              import QtPositioning 5.12
              import QtLocation 5.12
              
              Window {
                  visible: true
                  width: 400
                  height: 650
                  title: qsTr("Name app")
              
                  Loader
                            {
                                id: loader
                                anchors.fill: parent
                                //source: "Map.qml"
                                source: "QtMap.qml"
                            }
              }
              

              Where and how to add QQuickView ?

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #8

              @Mikeeeeee said in Map not working:

              Where and how to add QQuickView ?

              Don't, there is no need. You already have a Window, so no need to use QQuickView.

              Are you sure "QtMap.qml" is being found? Any warnings or error messages are printed? Is it in the same directory as your .exe file at runtime? (I'd expect QML file to be in Qt resource, but you seem to be using relative paths instead)

              (Z(:^

              1 Reply Last reply
              1
              • M Offline
                M Offline
                Mikeeeeee
                wrote on last edited by
                #9

                I get error: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
                The file is there, I see the text :"Page QtQml" on the screen. This text is in the map window.

                sierdzioS 1 Reply Last reply
                0
                • M Mikeeeeee

                  I get error: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
                  The file is there, I see the text :"Page QtQml" on the screen. This text is in the map window.

                  sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #10

                  @Mikeeeeee said in Map not working:

                  I get error: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed

                  Check your OpenSSL configuration.

                  The file is there, I see the text :"Page QtQml" on the screen. This text is in the map window.

                  Yes but do you see "Page with my map" text? I suspect the Loader is not seeing your QML file and can't load it.

                  Either that, or OpenSSL fail prevents maps from being downloaded.

                  (Z(:^

                  1 Reply Last reply
                  1
                  • M Offline
                    M Offline
                    Mikeeeeee
                    wrote on last edited by
                    #11

                    But the sample application works. How do I find and fix OpenSSL errors ?
                    The loader loaded the file, otherwise I would not have seen the text of this page.

                    JKSHJ 1 Reply Last reply
                    0
                    • sierdzioS Offline
                      sierdzioS Offline
                      sierdzio
                      Moderators
                      wrote on last edited by
                      #12

                      You cited completely different text so I assumed it has not loaded correctly.

                      (Z(:^

                      1 Reply Last reply
                      0
                      • M Mikeeeeee

                        But the sample application works. How do I find and fix OpenSSL errors ?
                        The loader loaded the file, otherwise I would not have seen the text of this page.

                        JKSHJ Offline
                        JKSHJ Offline
                        JKSH
                        Moderators
                        wrote on last edited by
                        #13

                        @Mikeeeeee said in Map not working:

                        How do I find and fix OpenSSL errors ?

                        Start by typing the error message into your search engine.

                        But the sample application works.

                        Did you use different versions of Qt?

                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          Mikeeeeee
                          wrote on last edited by
                          #14

                          No, I used 13.0. But this version normally compiled an example. So it's not about the compiler. The code that I showed above is correct, just that when migrating to another file, I changed the text of the label.

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            Mikeeeeee
                            wrote on last edited by
                            #15
                            This post is deleted!
                            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