[QT][QML] Unable to use QTLocation and QTPositioning in my QML view
-
Dear users,
in my QT/QML project created by using QT 6.1 / OS Ubuntu 20.04 I am using the QTMapView component. In order to complete my task, I tried to install QTLocation and QTPosition by using the following command:sudo apt install qml-module-qtlocation qml-module-qtpositioningAs suggested from the following topic:
https://askubuntu.com/questions/1115899/qtlocation-and-qtpositioning-not-installed
After that, I tried to import in my QML view the QTLocation and QTPosition with the following code
import QtLocation 5.12 import QtPositioning 5.12But I receive a "QML Module not found" message for both import.
Below, you can find also the CMakeLists.txt file of the project:
cmake_minimum_required(VERSION 3.14) project(myapp VERSION 0.1 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 COMPONENTS Core Quick REQUIRED) find_package(Qt6 COMPONENTS Core Quick REQUIRED) set(CMAKE_EXPORT_COMPILE_COMMANDS 1) set(PROJECT_SOURCES main.cpp qml.qrc images.qrc ) qt_add_executable(myapp MANUAL_FINALIZATION ${PROJECT_SOURCES} ) target_compile_definitions(myapp PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) target_link_libraries(myapp PRIVATE Qt6::Core Qt6::Quick) set_target_properties(myapp PROPERTIES QT_QML_MODULE_VERSION 1.0 QT_QML_MODULE_URI com.my.myapp ) list(APPEND QML_IMPORT_PATH .) qt6_qml_type_registration(myapp) qt_import_qml_plugins(myapp) qt_finalize_executable(myapp)Did I missed something? How can I solve the problem and import correctly the map components? Thank you very much; I tried to be more detailed as possible but if you need other info don't hesitate to ask me.
-
You need to add those modules to
find_packageandtarget_link_libraries
find_package(Qt COMPONENTS Core Quick Location Positioning REQUIRED)
target_link_libraries(myapp PRIVATE Qt::Core Qt::Quick Qt::Location Qt::Positioning)The bad news is that both those modules are still not ported to Qt 6. Positioning will come in 6.2 (scheduled for september 2021) while Location doesn't have a release date yet given the high dependency on OpenGL of that module.
-
First, thank you very much for your reply; you really saved me from a big time wasting.
- In this case I would ask, it is an other way to show a map inside a QML view without this component?
- If not, how can I simply downgrade my app to QML5 (EDIT: In case, I would also ask if it is possible to have 2 different QTCreator for 2 version, at the same time)?
Thanks again