(I am using Qt 5, QtQuick 2, with controls.)
I am writing my first QML application and want to support modularity and relatively short file length.
There are certain things that come in large batches that I would like to put in auxiliary files, but I'm not sure of the correct way to do this.
Two examples that I came across were FontLoaderand Action.
In my specific situation, I will use 6 fonts throughout my application, so I would like to download them all at an early stage, and I won’t have to worry about it again. My question is: where should I put FontLoaders?
One option is to just put them main.qmlsomewhere, but for me it is a bit cluttered. I created a file FontLoaders.qmlthat contains:
Item {
width: 0; height: 0
FontLoader {
name: "myFont1"
source: "/fonts/myFont1.ttf"
}
FontLoader {
name: "myFont2"
source: "/fonts/myFont2.ttf"
}
// ...
}
Then, main.qmlsomewhere, I just have it FontLoaders {}.
Another example: Action. I have a large batch Actionthat I would like to see more or less on an application scale. I have a component AppMenuBar, and this seems like a natural place to host Actions, but it basically doubles the size of the QML file defining the menu bar, and logically speaking, the two can be separated. (Many of these actions are available both through the menu bar and through other buttons in the application.)
"" , ( FontLoaders), , , .