Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [QT][QML] Unable to use QTLocation and QTPositioning in my QML view
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.9k Views
  • 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.
  • S Offline
    S Offline
    Shadow.01
    wrote on last edited by Shadow.01
    #1

    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-qtpositioning
    

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

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #4

      1 I don't know. there might be but i can't answer.
      2 sure, just use maintenancetool to install Qt 5.15 for your compiler. you don't need 2 separate Qt Creators, you can have multiple kits in the same ide

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #2

        You need to add those modules to find_package and target_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.

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2
        • S Offline
          S Offline
          Shadow.01
          wrote on last edited by Shadow.01
          #3

          First, thank you very much for your reply; you really saved me from a big time wasting.

          1. In this case I would ask, it is an other way to show a map inside a QML view without this component?
          2. 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

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #4

            1 I don't know. there might be but i can't answer.
            2 sure, just use maintenancetool to install Qt 5.15 for your compiler. you don't need 2 separate Qt Creators, you can have multiple kits in the same ide

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2
            • S Offline
              S Offline
              Shadow.01
              wrote on last edited by
              #5

              Thank you very much!

              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