Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
When to use .qml and when to use .ui.qml ?
Alan B last edited by
I'm new to Qt Quick/QML and struggling to understand when I should be using a straight QML file and when to use the Qt Quick UI File option.
I've watched various videos and some developers seem to use a UI File when developing a reusable component and others use a plain .qml when adding a form/view.
These almost seem interchangeable, in fact the UI File option just seems to append 'Form' to the name and use the .qml file almost like a header.
Are there any advantages/disadvantages of using either in certain situations (e.g. creating a reusable component or adding a form/page to an app) ?
Also, is there a 'best practice' to help decide which to use ?
Thanks in advance
fcarney last edited by fcarney
They can be used identically. The .ui. in the name just affects how Qt Creator will treat the file. It opens .ui. files in the designer instead of the text editor by default. At least that is how I understand them.
As for "best practices" I am not sure what that would be.
In the end it's totally up to you, use what gives you the most overview, or that what you have the most mastery over.
I personally have, in my 3 years of active QML usage never used a single
.ui.qmlfile nor a single
Qt Quick Layout
anchors and x/y bindings for life 🤘