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

Jérôme Godbout godboutj at amotus.ca
Mon Feb 18 04:49:25 CET 2019


Hi,
I strongly suggest you add your resource path to your qml import path. And start doing module into the resource (subfolder with qmldir file that list the exposed component). Note, you can append to resource path from multiple resource files, I used git submodules for more generic module that get append into the final resource of my projects by using .pri file inot the submodules.

It does keep clean split and allow code reused.

Hope this help to give you some idea to start with.

Jerome


________________________________
From: Interest <interest-bounces at qt-project.org> on behalf of mail at herrdiel.de <mail at herrdiel.de>
Sent: Sunday, February 17, 2019 5:42 AM
To: interest at qt-project.org
Subject: [Interest] Odd behaviour when organizing .qml files into folders

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


_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190218/6097c800/attachment.html>


More information about the Interest mailing list