[Interest] Odd behaviour when organizing .qml files into folders

mail at herrdiel.de mail at herrdiel.de
Sun Feb 17 11:42:07 CET 2019


Hi,

in order to keep a big project organized I understand that it is good
practice to have a structure of folders, each containing a bunch of code
files that belong  together. There must be a proper name for that, maybe
"project tree" or "code hierarchy" - I don't know (I am almost totally
self-taught).

The QtCreator, being a good IDE, further separates .h from .cpp files,
presenting them as different (virtual) folder structures. As a
speciality for Qt, the .qml files have been integrated as a folder
inside Sources.

Can you tell me a starting point for some "best practice" information on
how to achieve a proper folder hierarchy within that qml folder?
QtCreator behaves a little odd here, it seems to have two
"philosophies", interfering with one another.

My structure *before* having a subfolder for my .qml files (simplified a
lot):

Project
- myProject.pro
- Headers
- - src
- - - controller // many .h files in nested folder structures
- - - model  // many .h files in nested folder structures
- Sources
- - src
- - - controller // many .cpp files in nested folder structures
- - - model // many .cpp files in nested folder structures
- - qml
- - - qmlFile1.qml
- - - qmlFile2.qml
- - - qmlFile3.qml    // everything crammed into one folder without
hierarchy, in alphabetical order
- - - qmlFile4.qml
- - - qmlFile5.qml
- - main.cpp
- - qml.qrc // automagically organized by QtCreator, in chronological order

I would like to have an organizing folder structure for the .qml files,
too. But when I start doing this (for example with "add existing
directory"), QtCreator reacts "interestingly":

- #1: The new folder does *not* appear inside the qml folder, but inside
a new "top level" entry "QML", alongside Headers and Sources
- #2: Every file from the Sources/qml folder reappears here, as an entry
doublette
- #3: In myProject.pro all .qml files (incl. the new one) are being
added to DISTFILES (probably the reason for #2)
- #4: The resource file qml.qrc has not changed, the new file in the
subfolder is missing here.

Project
- myProject.pro
- Headers
- Sources
- - qml  // like before, without the new folder and file
- - main.cpp
- - qml.qrc // no entry for the new folder or the new file
- QML
- - newFolder
- - - newQmlFile.qml // << my new folder and file structure
- - qmlFile1.qml
- - qmlFile2.qml
- - qmlFile3.qml    // everything from Sources/qml reappears here
- - qmlFile4.qml
- - qmlFile5.qml

What is the recommended way to organize my .qml code base without having
entry doublettes? Is it possible to have qml.qrc working like before?

Thanks for reading!

Sebastian

- 
http://www.classintouch.de - Tablet-Software für Lehrer





More information about the Interest mailing list