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 Update on Monday, May 27th 2025

Correct way to make QML modules Qt 6.5-6.9

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
14 Posts 3 Posters 289 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.
  • R Redman
    14 days ago

    I build all my qmlmodules into a single folder

    set(QML_IMPORT_PATH
        ${CMAKE_BINARY_DIR}/qml
        CACHE STRING "" FORCE
    )
    

    With this your folder would look like this:
    qml
    ├── UI.Components
    ├── UI.otherModule

    And the import in your qml files would be "import UI.Components"

    D Offline
    D Offline
    Deymos
    wrote 14 days ago last edited by
    #5

    @Redman
    So it turns out that the working approach is to put everything in one folder and split the files into modules, then it will look divided in the project tree?

    R 1 Reply Last reply 14 days ago
    0
    • D Deymos
      14 days ago

      @Redman
      So it turns out that the working approach is to put everything in one folder and split the files into modules, then it will look divided in the project tree?

      R Offline
      R Offline
      Redman
      wrote 14 days ago last edited by Redman 5 Jul 2025, 09:48
      #6

      @Deymos Sorry, I forgot a piece of code.

      set(QML_IMPORT_PATH
          ${CMAKE_BINARY_DIR}/qml
          CACHE STRING "" FORCE
      )
      set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml)
      

      With this code you build all your modules into the qml folder. And you tell the qml engine where to look for modules if you do import statements in your qml files.

      If you then link against your module like you do in your repo you should be able to "import UI.Components"

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

      then it will look divided in the project tree?

      You can leave your structure the way it is.

      D 1 Reply Last reply 14 days ago
      0
      • R Redman
        14 days ago

        @Deymos Sorry, I forgot a piece of code.

        set(QML_IMPORT_PATH
            ${CMAKE_BINARY_DIR}/qml
            CACHE STRING "" FORCE
        )
        set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml)
        

        With this code you build all your modules into the qml folder. And you tell the qml engine where to look for modules if you do import statements in your qml files.

        If you then link against your module like you do in your repo you should be able to "import UI.Components"

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

        then it will look divided in the project tree?

        You can leave your structure the way it is.

        D Offline
        D Offline
        Deymos
        wrote 14 days ago last edited by Deymos 5 Jul 2025, 10:22
        #7

        @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

        R C 2 Replies Last reply 14 days ago
        0
        • D Deymos
          14 days ago

          @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

          R Offline
          R Offline
          Redman
          wrote 14 days ago last edited by
          #8

          @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 1 Reply Last reply 13 days ago
          0
          • D Deymos
            14 days ago

            @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 14 days ago last edited by
            #9
            This post is deleted!
            1 Reply Last reply
            0
            • R Redman
              14 days ago

              @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 13 days ago last edited by Deymos 5 Jul 2025, 21:08
              #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 13 days ago last edited by
                #11

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

                D 1 Reply Last reply 13 days ago
                0
                • R Redman
                  13 days ago

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

                  D Offline
                  D Offline
                  Deymos
                  wrote 13 days ago 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 13 days ago
                  0
                  • D Deymos
                    13 days ago

                    @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 13 days ago last edited by
                    #13

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

                    D 1 Reply Last reply 13 days ago
                    0
                    • R Redman
                      13 days ago

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

                      D Offline
                      D Offline
                      Deymos
                      wrote 13 days ago 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.

                      1 Reply Last reply
                      0
                      • D Deymos referenced this topic 5 days ago

                      14/14

                      8 May 2025, 07:49

                      • Login

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