Qt Quick Best Practices
The following guidelines describe the most efficient ways to use Qt Creator to create UIs and scenes that run flawlessly on the intended platforms.
For best practices in creating 3D scenes with optimized graphics performance, see Creating Optimized 3D Scenes.
Establish naming conventions to keep the items in your UI organized. Name your items accurately and give them suitable QML IDs. You should manually specify the names of the items you export from design tools to create reliable and self-explanatory names that follow the naming conventions you have established.
For example, a button symbol might have the ID myButton_symbol and the different layers might have it as a prefix with the states appended, thus producing IDs such as myButton_symbol_default. To prepare for additional mouse areas later in the project, you could use similar IDs for them, such as myButton_symbol_hotspot. When you use the button as instances in a screen, you would give each of these instances a unique ID that relates to that screen. For example, myButton_myMenu_home, myButton_myMenu_profile, and myButton_myMenu_settings
Plan your UI properly. Know what elements, such as screens, components, and states, you need. Creating a descriptive wireframe and acquiring a detailed UI specification before you start will make the process of creating the UI more efficient.
It is important to understand the performance costs associated with using components.
To use components efficiently and economically:
- Componentize your design by packaging your resources into reusable components that can be conveniently recombined to suit the needs of your UI.
- Use as few components as necessary. To minimize the number of components, use alias properties and states to create the differences in your instances. We recommend reusing components instead of duplicating them, so the components do not need to be processed as completely new types. This reduces loading and compilation time as well as the size of the binary.
- Any content that is data-driven should be exported as a public property of the relevant component. For example, a speedometer should have an
realproperty for speed to which the UI is bound.
© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.