Unsolved 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?
-
The application compiles, but the map does not appear. But it is an example of "places_map" compiles and the map is working.
-
@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 } } }
-
I have just tried your code and it works for me.
I just had to change
Item
toWindow
as my main component, because I don't use QQuickView (chances are you are not using it either). -
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)
-
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. -
@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.
-
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. -
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?
-
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.
-
This post is deleted!