Correct way to make QML modules Qt 6.5-6.9
-
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.otherModuleAnd the import in your qml files would be "import UI.Components"
-
@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?wrote 14 days ago last edited by Redman 5 Jul 2025, 09:48@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.
-
@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.
wrote 14 days ago last edited by Deymos 5 Jul 2025, 10:22@Redman
wow, seems to this approach is working
but I have a little trouble, I got this
But file is present and in correct path
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
-
@Redman
wow, seems to this approach is working
but I have a little trouble, I got this
But file is present and in correct path
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
wrote 14 days ago last edited by@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?
-
@Redman
wow, seems to this approach is working
but I have a little trouble, I got this
But file is present and in correct path
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
wrote 14 days ago last edited byThis post is deleted! -
@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?
wrote 13 days ago last edited by Deymos 5 Jul 2025, 21:08some 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.
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.
But in the end, HomePage creates, but Components(MButton) does not see.
If i removed MButton and starting with only HomePage (from UI.Pages):
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
-
wrote 13 days ago last edited by
set(QT_QML_GENERATE_QMLLS_INI OFF)
can you remove this and try again? -
wrote 13 days ago last edited by
@Redman
So I commented this line and deleted the build folder
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 -
@Redman
So I commented this line and deleted the build folder
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 -
14/14