Use Qt Designer or QML for Graphical User Interface?
-
Hello,
I'm trying to do a Windows and an Android app wtih the same Graphic User Interface.
For the Windows app, I used Qt Designer, but when I try to launch the app on Android I get the following error "member access into incomplete type "Ui::mainwindow".
I saw a lot of tutorials on internet where QML and JavaScript is used for Android app.
So do I need to use Qt Designer, or QML? Also what is the difference between a QML File (.qml) and a QtQuick UI File (.ui.qml)?
Thanks
-
What you refer to by "Qt Designer" is a UI based on Qt Widgets module.
I get the following error "member access into incomplete type "Ui::mainwindow".
That's a compilation error. Make sure your .ui file is added to FORMS qmake variable (in your .pro file), run qmake and rebuild your project.
So do I need to use Qt
DesignerWidgets, or QML?Both should work on Android. QML is much better suited for mobile platforms, touch displays, animations etc. so it is usually preferred over QtWidgets on mobiles - but it's not a requirement.
Also what is the difference between a QML File (.qml) and a QtQuick UI File (.ui.qml)?
.ui.qml is used by Qt QML Designer when you create the UIs in the wysiwyg editor. The .ui.qml contains UI definitions, while the corresponding .qml all the UI logic.
From perspective of QML engine, .ui.qml is a normal QML file.
My personal, 100% biased opinion: .ui.qml approach is rubbish ;-) I very strongly prefer coding in "normal" QML files. But I usually write QML code by hand - that's why for me the .ui.qml makes no sense.
-
@Damalo_02 said in Use Qt Designer or QML for Graphical User Interface?:
Thanks a lot for your answer. I have one last question, can I use QML for Windows app? Or is it more convenient to use Qt Widgets module?
You can use QML on Windows (and any other desktop platform).
About convenience - well depends. If you already have a QML app written for mobiles, then running the same code on Windows is the easiest and most convenient way. Or, in some cases (depends on UI design) you may want to create a variant of your QML code better suited for desktops.
If you don't have plans to support mobile platforms, then QtWidgets are a very good option for desktops.
Yeah, so unfortunately there is no easy answer here ;-) You can use either QtWidgets or QtQuick (another name for QML) on all platforms. Which suits your needs better depends on details of the task, and on personal preference.