Details
-
Epic
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
QML Form File Tooling
Description
Qt tooling differentiates between .ui.qml and .qml files - the former are meant to be created and updated with tools, the latter is free to be edited by the user. People are confused about the split though, and don't follow best practices.
Challenges
We have identified following challenges users face with .ui.qml and .qml files:
Naming conflicts
If you want to implement your custom type MyDialog with the help of visual tooling, it feels natural to start off with a MyDialog.ui.qml, and put the custom implementation logic in MyDialog.qml. But the engine ignores the suffixes early on, making it impossible to differentiate between both types at runtime. In particular, it is not possible to reference the type defined in the MyDialog.ui.qml file inside MyDialog.qml.
User editing .ui.qml files in a non-compatible way
If developers starting with .ui.qml files want to implement custom logic, the easiest way is to add the logic directly to the .ui.qml file. Anyhow, this might easily break the visual editor.
Suggestions
Establish naming convention for .ui.qml file
We could establish that .ui.qml files should also have a common suffix, like Form. This would make naming conflicts with a matching .qml file less likely.
qmllint should check .ui.qml files for compatibility
qmllint could be extended to warn about changes to .ui.qml files that do not match the subset supported by the visual editor.
Allow user to merge .ui.qml into.qml file
It should be easy from within Qt Creator to merge a .ui.qml file into a .qml file, or rename a .ui.qml to a .qml file.
Allow user to split .qml file into .ui.qml and .qml file
The reverse operation is also handy: Extracting the declarative part of an existing .qml file into a .ui.qml file.
References
https://doc.qt.io/qtcreator/creator-quick-ui-forms.html
https://doc.qt.io/qtdesignstudio/studio-designer-developer-workflow.html