How to seperate QML components
-
wrote on 9 Dec 2014, 09:43 last edited by
i want to seperate the different parts of the GUI, in QtQuick UI project, i can put seperate parts in seperated files, but after using subdirs to categorize qml files code is not working. (i use this project for prototyping purpose)
and i have no idea how to do that in Qt Quick application project! (and this project for final deployment)
any help? -
Please tell us more about the errors you are getting.
You can include files from other directories in QML like this:
@
import "some/other/directory"
@ -
wrote on 9 Dec 2014, 10:48 last edited by
i have a subdir called Components
and i import it like this:
@import "Components/TopBar.qml"@
and
@
TopBar {
...
}
@
but i get
@"Components/TopBar.qml": no such directory@and what about QtQuick Application? how to use seperated components?
-
Do not import files, import directories. Also, make sure the QML files are all available where your application is looking for them (QRC file, or deployment directory).
[quote]and what about QtQuick Application? how to use seperated components?[/quote]
I do not understand those questions, please elaborate.
-
wrote on 9 Dec 2014, 15:57 last edited by
thank you, first one is working now :-)
and about the second question, i mean when i choose a Qt Quick application in new project wizard, how can i seperate qml components?
because in this case, main qml file will be used in main.cpp file from resources system, so the first method will not work. -
You can create multiple files and folders inside the resource file. Using Qt resource system has the advantage that you do not need to copy the QML files together with your binary file - the resource is already included into the executable itself.
But if you don't like that, you can simply remove the resource and change the QML file URL to point to the physical file and it will work - the same as in your first case.
-
wrote on 10 Dec 2014, 19:46 last edited by
i got it, thank you a lot :-)
3/7