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. qrc:/mainQml.qml:4:1: module "QmlApp" is not installed

qrc:/mainQml.qml:4:1: module "QmlApp" is not installed

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 1.6k 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.
  • D Offline
    D Offline
    Diego Iastrubni
    wrote on 21 Mar 2023, 07:54 last edited by Diego Iastrubni
    #1

    I am trying to build a AppImage for my Qt6 app. It uses internally QML. When I run it I get this error:

    qrc:/mainQml.qml:4:1: module "QmlApp" is not installed 
    

    For what I understand, the QML runtime is not properly installed on the AppImage - which should be installed.

    My CMake has qt_add_qml_module (this should deploy on install, no?).

    The script I use to create the AppImage is this:

    cmake -S . -B cbuild -G Ninja -DCMAKE_BUILD_TYPE=Release 
    cmake --build cbuild
    cmake --install cbuild --prefix=`pwd`/cbuild/AppDir/usr/
    # failed experiment - this does not help
    cp -r $QT_DIR/qml `pwd`/cbuild/AppDir/usr/
    
    cd cbuild
    wget --no-verbose "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
    wget --no-verbose "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"
    
    chmod +x linuxdeploy*.AppImage
    export OUTPUT=PassSimpleQt-x86_64.AppImage
    export LD_LIBRARY_PATH=AppDir/usr/lib/:$LD_LIBRARY_PATH
    #export DEBUG=1
    ./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin qt --output appimage
    

    What am I missing?

    Edit - relevant part of CMakeLists.txt:

    qt_add_qml_module(pass-simple
        URI MainQml
        VERSION 1.0
        SOURCES
            mainqmltype.h mainqmltype.cpp
            GpgIdManageType.h GpgIdManageType.cpp
            UiGuard.h UiGuard.cpp
            InputType/totp.h
            InputType/totp.cpp
            InputType/Base32.h
            InputType/Base32.cpp
            InputType/Clock.h
            InputType/Clock.cpp
      AppSettings.cpp AppSettings.h
            # hygen srcs
        QML_FILES mainQml.qml
    )
    
    
    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on 21 Mar 2023, 08:20 last edited by
      #2

      hi can you please copy/paste the full qt_add_qml_module from your CMakeLists.txt ?

      D 1 Reply Last reply 21 Mar 2023, 08:33
      0
      • ? A Former User
        21 Mar 2023, 08:20

        hi can you please copy/paste the full qt_add_qml_module from your CMakeLists.txt ?

        D Offline
        D Offline
        Diego Iastrubni
        wrote on 21 Mar 2023, 08:33 last edited by
        #3

        @ankou29666 I edited the main question.

        D J 2 Replies Last reply 23 Mar 2023, 15:46
        0
        • D Diego Iastrubni
          21 Mar 2023, 08:33

          @ankou29666 I edited the main question.

          D Offline
          D Offline
          Diego Iastrubni
          wrote on 23 Mar 2023, 15:46 last edited by
          #4

          bumping this up,in case anyone knows the answer

          1 Reply Last reply
          0
          • D Diego Iastrubni
            21 Mar 2023, 08:33

            @ankou29666 I edited the main question.

            J Offline
            J Offline
            JKSH
            Moderators
            wrote on 25 Mar 2023, 14:19 last edited by
            #5

            @Diego-Iastrubni said in qrc:/mainQml.qml:4:1: module "QmlApp" is not installed:

            I edited the main question.

            I don't see any module called QmlApp in your CMakeLists.txt

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            D 1 Reply Last reply 25 Mar 2023, 17:36
            0
            • J JKSH
              25 Mar 2023, 14:19

              @Diego-Iastrubni said in qrc:/mainQml.qml:4:1: module "QmlApp" is not installed:

              I edited the main question.

              I don't see any module called QmlApp in your CMakeLists.txt

              D Offline
              D Offline
              Diego Iastrubni
              wrote on 25 Mar 2023, 17:36 last edited by
              #6

              @JKSH thanks, that oviously was a start..
              I have inside this app, a sub directory which contains:

              qt6_add_qml_module(QmlApp
                      URI QmlApp
                      VERSION 1.0
                      SOURCES
              ...
              

              OK - lets try and install it. I added at the end:

              install(TARGETS QmlApp
                  BUNDLE DESTINATION .
                  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
              

              Still no go. I added to my build shell script:

              cp -r QmlApp/*.qml  `pwd`/cbuild/AppDir/usr/qml/QmlApp/
              

              This still does not work. I looked at the documentation (https://doc.qt.io/qt-6/cmake-build-reusable-qml-module.html ) and it does not explain how/where to install QML modules.

              I found this example, which (IMHO) shows that "I am doing the correct thing". So, I am kinda lost...

              https://github.com/4rtzel/cmake-qml-plugin-example/blob/master/plugins/my/plugin/example/CMakeLists.txt

              J 1 Reply Last reply 26 Mar 2023, 16:01
              0
              • D Diego Iastrubni
                25 Mar 2023, 17:36

                @JKSH thanks, that oviously was a start..
                I have inside this app, a sub directory which contains:

                qt6_add_qml_module(QmlApp
                        URI QmlApp
                        VERSION 1.0
                        SOURCES
                ...
                

                OK - lets try and install it. I added at the end:

                install(TARGETS QmlApp
                    BUNDLE DESTINATION .
                    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
                

                Still no go. I added to my build shell script:

                cp -r QmlApp/*.qml  `pwd`/cbuild/AppDir/usr/qml/QmlApp/
                

                This still does not work. I looked at the documentation (https://doc.qt.io/qt-6/cmake-build-reusable-qml-module.html ) and it does not explain how/where to install QML modules.

                I found this example, which (IMHO) shows that "I am doing the correct thing". So, I am kinda lost...

                https://github.com/4rtzel/cmake-qml-plugin-example/blob/master/plugins/my/plugin/example/CMakeLists.txt

                J Offline
                J Offline
                JKSH
                Moderators
                wrote on 26 Mar 2023, 16:01 last edited by
                #7

                @Diego-Iastrubni said in qrc:/mainQml.qml:4:1: module "QmlApp" is not installed:

                OK - lets try and install it.

                My suggestion: Don't install it manually.

                And definitely don't cp the files manually. Rather, let qt_add_qml_module() auto-generate the required files and put everything in the right place.

                1. In your subdirectory's CMakeLists.txt, add the STATIC keyword to qt6_add_qml_module(QmlApp ...) to generate a static library.
                2. In your top-level CMakeLists.txt, add add_subdirectory(QmlApp) to build the static library together with your main app
                3. In your top-level CMakeLists.txt, add target_link_libraries(pass-simple PRIVATE QmlAppplugin) to link to the static library.

                This way, your QML module is embedded directly inside your application and gets auto-initialized.

                P.S. What version of Qt are you using? The upcoming Qt 6.5 makes some changes to the default QML resource paths

                I found this example, which (IMHO) shows that "I am doing the correct thing". So, I am kinda lost...
                https://github.com/4rtzel/cmake-qml-plugin-example/blob/master/plugins/my/plugin/example/CMakeLists.txt

                That example is very low-level, and is not very suitable for QML modules.

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  Diego Iastrubni
                  wrote on 26 Mar 2023, 18:21 last edited by
                  #8

                  my top level cmake contains:

                  add_subdirectory(QmlApp)
                  ...
                  qt_add_qml_module(pass-simple
                      URI MainQml
                      VERSION 1.0
                      SOURCES
                          mainqmltype.h mainqmltype.cpp
                          GpgIdManageType.h GpgIdManageType.cpp
                          UiGuard.h UiGuard.cpp
                          InputType/totp.h
                          InputType/totp.cpp
                          InputType/Base32.h
                          InputType/Base32.cpp
                          InputType/Clock.h
                          InputType/Clock.cpp
                          AppSettings.cpp AppSettings.h
                      QML_FILES mainQml.qml
                  )
                  
                  target_link_libraries(pass-simple PRIVATE
                      Qt::Widgets
                      Qt::QuickWidgets
                      Qt6::Concurrent
                      Qt6::LabsFolderListModel
                      QmlApp
                      EditYaml
                      InputType
                      DropdownWithList
                      Datetime
                      libpgpfactory
                      yaml-cpp
                  )
                  

                  Then my QmlApp/CMakeLists.txt contains:

                  qt6_add_qml_module(QmlApp
                          URI QmlApp
                          VERSION 1.0
                          STATIC
                          SOURCES
                              QmlAppType.h 
                  ....
                  
                  install(TARGETS QmlApp
                      BUNDLE DESTINATION .
                      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
                  

                  Still the same error on runtime. I can also see the same error when I run from the command line - without QtCreator.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    JKSH
                    Moderators
                    wrote on 12 Jul 2023, 03:25 last edited by JKSH 7 Dec 2023, 03:34
                    #9

                    Sorry for the delay.

                    @Diego-Iastrubni said in qrc:/mainQml.qml:4:1: module "QmlApp" is not installed:

                    my top level cmake contains:

                    add_subdirectory(QmlApp)
                    ...
                    target_link_libraries(pass-simple PRIVATE
                        ...
                        QmlApp
                        ...
                    )
                    

                    Link to QmlAppplugin instead of QmlApp

                    Still the same error on runtime. I can also see the same error when I run from the command line - without QtCreator.

                    I asked for the version of Qt that you're using, but didn't get an answer. Anyway, see https://www.qt.io/blog/whats-new-for-qml-modules-in-6.5 -- Use Qt 6.5, add qt_standard_project_setup(REQUIRES 6.5) to your top-level CMakeLists.txt and call engine.loadFromModule() instead of engine.load()

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    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