Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Correct way to make QML modules Qt 6.5-6.9
Forum Updated to NodeBB v4.3 + New Features

Correct way to make QML modules Qt 6.5-6.9

Scheduled Pinned Locked Moved Solved QML and Qt Quick
18 Posts 4 Posters 1.9k Views 3 Watching
  • 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 Deymos
    7 May 2025, 10:14

    @Redman
    wow, seems to this approach is working
    but I have a little trouble, I got this
    a6e8513f-2d3c-4e7d-a7dc-9798555f5253-image.png

    But file is present and in correct path
    05a1afa3-439f-4fea-9543-1d4d0d674ea3-image.png

    after cleaning the build, the error from Qt creator disappeared, but the "module "UI.Pages" is not installed" remained at startup.

    on work pc i have only Qt 6.2.0, i will also try on 6.9.0 6 hours later

    C Offline
    C Offline
    CassD
    wrote on 7 May 2025, 16:30 last edited by
    #9
    This post is deleted!
    1 Reply Last reply
    0
    • R Redman
      7 May 2025, 13:02

      @Deymos said in Correct way to make QML modules Qt 6.5-6.9:

      but the "module "UI.Pages" is not installed" remained at startup.

      What does that mean?

      D Offline
      D Offline
      Deymos
      wrote on 7 May 2025, 21:08 last edited by Deymos 7 days from now
      #10

      @Redman

      some incredibly strange behavior, I added QML_IMPORT_PATH, my HomePage from the module UI.Pages was created and displayed a message to me, but the module UI.Components is still nowhere to be seen, although there are no special rules for it.
      0d30c809-6d2f-4822-9d43-1c5d58759558-изображение.png
      It issues these warnings.
      Before I deleted the build folder, the warnings were displayed only for the UI.Assets, maybe the QML language server is buggy, I do not know.
      25c2af26-f61b-43a3-a626-1fdae78bea80-изображение.png

      But in the end, HomePage creates, but Components(MButton) does not see.
      If i removed MButton and starting with only HomePage (from UI.Pages):
      5cbfb4a5-2cd2-4b97-b75d-f753e4671ad2-изображение.png

      Very strange, they just the same modules, with the same connection way.

      I'm updated repo, if you want to look or test https://github.com/Deymoss/MoneyTogether

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Redman
        wrote on 8 May 2025, 07:14 last edited by
        #11

        set(QT_QML_GENERATE_QMLLS_INI OFF) can you remove this and try again?

        D 1 Reply Last reply 8 May 2025, 07:22
        0
        • R Redman
          8 May 2025, 07:14

          set(QT_QML_GENERATE_QMLLS_INI OFF) can you remove this and try again?

          D Offline
          D Offline
          Deymos
          wrote on 8 May 2025, 07:22 last edited by
          #12

          @Redman
          So I commented this line and deleted the build folder
          67bfdc28-d93d-4583-803f-f8c8e48fbc61-image.png
          But unfortunately nothing is changed, probably this approach of moduling is not working and I need an add_library(STATIC) on each module, but I really don't want to, because there will be a mountain of garbage in the project tree.
          Or something missing

          R 1 Reply Last reply 8 May 2025, 07:32
          0
          • D Deymos
            8 May 2025, 07:22

            @Redman
            So I commented this line and deleted the build folder
            67bfdc28-d93d-4583-803f-f8c8e48fbc61-image.png
            But unfortunately nothing is changed, probably this approach of moduling is not working and I need an add_library(STATIC) on each module, but I really don't want to, because there will be a mountain of garbage in the project tree.
            Or something missing

            R Offline
            R Offline
            Redman
            wrote on 8 May 2025, 07:32 last edited by
            #13

            @Deymos To hide the "garbage" you can do
            1aed6aa9-49bc-4a53-883a-4124ee2bde23-image.png

            D 1 Reply Last reply 8 May 2025, 07:49
            0
            • R Redman
              8 May 2025, 07:32

              @Deymos To hide the "garbage" you can do
              1aed6aa9-49bc-4a53-883a-4124ee2bde23-image.png

              D Offline
              D Offline
              Deymos
              wrote on 8 May 2025, 07:49 last edited by
              #14

              @Redman
              Yeah, I've seen this option.
              Thank you very much for your help, I will keep an eye on updates, and as soon as there is a way to make everything working in Qt, I will write in this thread and mark it as solved.

              J 1 Reply Last reply 23 May 2025, 13:29
              0
              • D Deymos referenced this topic on 16 May 2025, 07:13
              • D Deymos
                8 May 2025, 07:49

                @Redman
                Yeah, I've seen this option.
                Thank you very much for your help, I will keep an eye on updates, and as soon as there is a way to make everything working in Qt, I will write in this thread and mark it as solved.

                J Offline
                J Offline
                JKSH
                Moderators
                wrote on 23 May 2025, 13:29 last edited by JKSH
                #15

                @Deymos said in Correct way to make QML modules Qt 6.5-6.9:

                HomePage creates, but Components(MButton) does not see.

                To make it work:

                1. Order matters. You must set QT_QML_OUTPUT_DIRECTORY before your very first call to qt_add_qml_module()
                  • This ensures that the setting is applied to every QML module in your project.
                2. Set QT_QML_OUTPUT_DIRECTORY to ${CMAKE_BINARY_DIR}, not ${CMAKE_BINARY_DIR}/qml.
                  • This puts the QML module folders at the same level as your executable, so the executable can automatically find the modules and plugins at runtime (when you run it directly from your build dir)
                  • I tested this on Windows and Ubuntu
                3. To use MButton, you need import UI.Components and not import UI.Assets

                Note: There is no point linking your executable to Assets, Components, and Pages libraries because your executable does not use any C++ symbols from those libraries. Instead, you need your executable to find the QML plugins at runtime.

                @Deymos said in Correct way to make QML modules Qt 6.5-6.9:

                on work pc i have only Qt 6.2.0

                Qt 6.2 is far too old. QML modules have changed a lot since then.

                @Deymos said in Correct way to make QML modules Qt 6.5-6.9:

                I added QML_IMPORT_PATH

                QML_IMPORT_PATH is used by Qt Creator's old code model. It is not used by the new QML Language Server (qmlls). Likewise, QT_QML_GENERATE_QMLLS_INI is only used by qmlls and not the old code model.

                By default, you'll be using qmlls if:

                • You're running the latest Qt Creator, AND
                • You're using Qt 6.8 or newer for your project

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

                D 1 Reply Last reply 23 May 2025, 16:04
                1
                • J JKSH
                  23 May 2025, 13:29

                  @Deymos said in Correct way to make QML modules Qt 6.5-6.9:

                  HomePage creates, but Components(MButton) does not see.

                  To make it work:

                  1. Order matters. You must set QT_QML_OUTPUT_DIRECTORY before your very first call to qt_add_qml_module()
                    • This ensures that the setting is applied to every QML module in your project.
                  2. Set QT_QML_OUTPUT_DIRECTORY to ${CMAKE_BINARY_DIR}, not ${CMAKE_BINARY_DIR}/qml.
                    • This puts the QML module folders at the same level as your executable, so the executable can automatically find the modules and plugins at runtime (when you run it directly from your build dir)
                    • I tested this on Windows and Ubuntu
                  3. To use MButton, you need import UI.Components and not import UI.Assets

                  Note: There is no point linking your executable to Assets, Components, and Pages libraries because your executable does not use any C++ symbols from those libraries. Instead, you need your executable to find the QML plugins at runtime.

                  @Deymos said in Correct way to make QML modules Qt 6.5-6.9:

                  on work pc i have only Qt 6.2.0

                  Qt 6.2 is far too old. QML modules have changed a lot since then.

                  @Deymos said in Correct way to make QML modules Qt 6.5-6.9:

                  I added QML_IMPORT_PATH

                  QML_IMPORT_PATH is used by Qt Creator's old code model. It is not used by the new QML Language Server (qmlls). Likewise, QT_QML_GENERATE_QMLLS_INI is only used by qmlls and not the old code model.

                  By default, you'll be using qmlls if:

                  • You're running the latest Qt Creator, AND
                  • You're using Qt 6.8 or newer for your project
                  D Offline
                  D Offline
                  Deymos
                  wrote on 23 May 2025, 16:04 last edited by
                  #16

                  @JKSH
                  Thanks for answer, QT_QML_OUTPUT_DIRECTORY on top of qt_add_qml_module() really helped and now everything is working fine!

                  @JKSH said in Correct way to make QML modules Qt 6.5-6.9:

                  To use MButton, you need import UI.Components and not import UI.Assets

                  my bad, my eyes were busy with the warnings and I didn't notice :)

                  @JKSH said in Correct way to make QML modules Qt 6.5-6.9:

                  QML_IMPORT_PATH is used by Qt Creator's old code model. It is not used by the new QML Language Server (qmlls). Likewise, QT_QML_GENERATE_QMLLS_INI is only used by qmlls and not the old code model.

                  By default, you'll be using qmlls if:

                  You're running the latest Qt Creator, AND
                  You're using Qt 6.8 or newer for your project
                  

                  So can i use modules with "old" approach if I have Qt 6.5 and 16 creator? What is the difference when using without QMLLS on Qt 6.5? or is it the same, just don't write QT_QML_GENERATE_QMLLS_INI and add QML_IMPORT_PATH?

                  @JKSH said in Correct way to make QML modules Qt 6.5-6.9:

                  Note: There is no point linking your executable to Assets, Components, and Pages libraries because your executable does not use any C++ symbols from those libraries

                  and if I use C++ in this module, as I understand it, I will just need to link these modules, and the behavior will remain the same?

                  J 1 Reply Last reply 27 May 2025, 08:37
                  0
                  • D Deymos
                    23 May 2025, 16:04

                    @JKSH
                    Thanks for answer, QT_QML_OUTPUT_DIRECTORY on top of qt_add_qml_module() really helped and now everything is working fine!

                    @JKSH said in Correct way to make QML modules Qt 6.5-6.9:

                    To use MButton, you need import UI.Components and not import UI.Assets

                    my bad, my eyes were busy with the warnings and I didn't notice :)

                    @JKSH said in Correct way to make QML modules Qt 6.5-6.9:

                    QML_IMPORT_PATH is used by Qt Creator's old code model. It is not used by the new QML Language Server (qmlls). Likewise, QT_QML_GENERATE_QMLLS_INI is only used by qmlls and not the old code model.

                    By default, you'll be using qmlls if:

                    You're running the latest Qt Creator, AND
                    You're using Qt 6.8 or newer for your project
                    

                    So can i use modules with "old" approach if I have Qt 6.5 and 16 creator? What is the difference when using without QMLLS on Qt 6.5? or is it the same, just don't write QT_QML_GENERATE_QMLLS_INI and add QML_IMPORT_PATH?

                    @JKSH said in Correct way to make QML modules Qt 6.5-6.9:

                    Note: There is no point linking your executable to Assets, Components, and Pages libraries because your executable does not use any C++ symbols from those libraries

                    and if I use C++ in this module, as I understand it, I will just need to link these modules, and the behavior will remain the same?

                    J Offline
                    J Offline
                    JKSH
                    Moderators
                    wrote on 27 May 2025, 08:37 last edited by
                    #17

                    You're welcome! Glad to hear that it's now working for you.

                    @Deymos said in Correct way to make QML modules Qt 6.5-6.9:

                    So can i use modules with "old" approach if I have Qt 6.5 and 16 creator?

                    Yes. You could also do one of:

                    • Force the "old" code model for all projects by turning off qmlls completely
                    • Force qmlls to be used even if you're using an older kit

                    https://doc.qt.io/qtcreator/creator-how-to-use-qml-language-server.html

                    What is the difference when using without QMLLS on Qt 6.5? or is it the same, just don't write QT_QML_GENERATE_QMLLS_INI and add QML_IMPORT_PATH?

                    Yes, that's right. Although it's harmless to have both QT_QML_GENERATE_QMLLS_INI and QML_IMPORT_PATH in your project (the main problem is that it's a bit "noisy" and might confuse a reader).

                    The "old" code model is part of the Qt Creator IDE; qmlls is part of the Qt libraries. So qmlls gets updated with each Qt release. You can choose to use the version of qmlls that comes with your kit, or you can choose to use the newest available qmlls on your machine.

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

                    D 1 Reply Last reply 27 May 2025, 15:01
                    0
                    • J JKSH
                      27 May 2025, 08:37

                      You're welcome! Glad to hear that it's now working for you.

                      @Deymos said in Correct way to make QML modules Qt 6.5-6.9:

                      So can i use modules with "old" approach if I have Qt 6.5 and 16 creator?

                      Yes. You could also do one of:

                      • Force the "old" code model for all projects by turning off qmlls completely
                      • Force qmlls to be used even if you're using an older kit

                      https://doc.qt.io/qtcreator/creator-how-to-use-qml-language-server.html

                      What is the difference when using without QMLLS on Qt 6.5? or is it the same, just don't write QT_QML_GENERATE_QMLLS_INI and add QML_IMPORT_PATH?

                      Yes, that's right. Although it's harmless to have both QT_QML_GENERATE_QMLLS_INI and QML_IMPORT_PATH in your project (the main problem is that it's a bit "noisy" and might confuse a reader).

                      The "old" code model is part of the Qt Creator IDE; qmlls is part of the Qt libraries. So qmlls gets updated with each Qt release. You can choose to use the version of qmlls that comes with your kit, or you can choose to use the newest available qmlls on your machine.

                      D Offline
                      D Offline
                      Deymos
                      wrote on 27 May 2025, 15:01 last edited by
                      #18

                      @JKSH
                      Thanks for the answers!

                      1 Reply Last reply
                      0
                      • D Deymos has marked this topic as solved on 27 May 2025, 15:03

                      18/18

                      27 May 2025, 15:01

                      • Login

                      • Login or register to search.
                      18 out of 18
                      • First post
                        18/18
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved