Score:1

[QT][QML] Unable to use QTLocation and QTPositioning in my QML view

es flag

in my QT/QML project created with QT 6.1 and operating system Ubuntu 20.04 I would use the QTMapView. In order to do this, I tried to install QTLocation and QTPosition by using the following command:

sudo apt install qml-module-qtlocation qml-module-qtpositioning

As suggested from the following topic:

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.12

But 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.

Score:1
zw flag

You are creating additional problems by using Qt 6.1 on Ubuntu 20.04 LTS. This version ships Qt 5.12. The future of all Qt 6 is unclear for both Debian and Ubuntu.

So open terminal and install needed development packages for Qt from official repository:

sudo apt-get install qtlocation5-dev qtpositioning5-dev

and then compile your possibly great application.

Archimede avatar
es flag
First, thanks for your reply; I tried all your steps, installed also 5 version and everything works; but the problem is that, for my current project I should use QT6. But I have a question, in what sense is the future of QT 6 unclear? I am worried; do you mean that the project could be abandoned or that is unstable? If you were start a new big project now, which version would you use?
N0rbert avatar
zw flag
Currently Qt6 is not maintained in Debian. This means that Qt6 future is unclear. If you plan to ship your application in Ubuntu and Debian you have to choose supported Qt version - in Ubuntu 20.04 LTS it is 5.12, in Debian you can't get Qt version higher [than 5.15](https://packages.debian.org/search?suite=all&section=all&arch=any&searchon=names&keywords=qt+base+dev). If you plan to develop it as AppImage you can use Qt6 with no doubt, IMHO.
Archimede avatar
es flag
Ah ok, now I understand. Apart of the operating system (I could choose any, also Mac / Win), if you were start a big project now, which version would you use? Thanks!
N0rbert avatar
zw flag
Latest mature and stable, something like 5.x.
Archimede avatar
es flag
Ok, thank you very much!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.