Map not working
-
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)
-
That's a warning in Qt Creator, right? But when you run the application it works?
-
@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
-
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 } } }
-
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 ?
-
@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)
-
@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.
-
You cited completely different text so I assumed it has not loaded correctly.
-
@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?