Is there difference between WYSIWYG editor and code to get UI file
-
I mostly like to use wysiwyg editor as I like it's simplicity. Later it gets converted to
ui_filename.h which is almost same as of codingAre there benefits of using code over the editor??
Please share on following things
Performance
Maintainibility
Easyand the signals and slots
custom signal and slots take more time to manage and the code becomes too long.
Whereas when I use "Go to slot " it manages automatically.
So overall which one is best "WYSIWYG" or "CODE" -
@Thank-You
As you say, the designer saves a.ui
file from what you design. Then when you build it runs auic
process to read that.ui
and produce C++ code in a.h
file. So using the editor ends up producing code, it's just that it's done for you.The Designer is nice if you like that way of seeing what you have as you design. But it only does a tiny subset of what you can do in code. Sooner or later you have to write your own code to do more than Designer produces for you.
I would use the designer for static forms. It doesn't help you at all if you want to create widgets dynamically at runtime, or if you want to change their style/appearance/behaviour while the code is running. I would suggest not bothering at all with its signal/slot support. That doesn't do much, and gets confusing. To use Qt effectively, you need to understand how to write & connect signals & slots anyway, so you might as well get used to that. I do not share your opinion that "custom signal and slots take more time to manage and the code becomes too long.". All the Designer produces is a single
connect()
. -
@Thank-You said in Is there difference between WYSIWYG editor and code to get UI file:
Are there benefits of using code over the editor??
Please share on following things
PerformanceYou loose a tiny amount of time for .ui -> .h conversion. This happens once, during project compilation only. At runtime there is no performance difference.
Maintainibility
This is up to personal preference.
In QtWidgets, I usually use the .ui files and the editor. It is easy to maintain except for refactoring which often gets tricky.
In QtQuick, I prefer raw .qml files. But it's all up to you (and your team, if it is a bigger project).
Easy
Editor wins here.
and the signals and slots
custom signal and slots take more time to manage and the code becomes too long.Well, you still have to manage this code later :-) But yes, it is very convenient to have a generator like this.
So overall which one is best "WYSIWYG" or "CODE"
I don't think there is a clear winner. Everybody has different preferences and different projects have different needs.
-
Hi
Disclaimer: Im a diehard WYSIWYG lover..Performance
well, UI files become code so runtime there is no performance difference.
Compiles, it does take time - but seems very minor compared to the actual c++ compile.Maintainibility
Well UI files are easier to change for people not normally involved in the user interface and
personally, it's also easier when you come back to a project after some time.
For a complex interface, it's vastly faster to gain an overview of what layout is inside what layout just looking at the UI tree then browse through pages of code. For a simple layout, it doesn't matter so much as the amount of code is small.Easy
Even my colleagues that never do HMI can add a button by dragging it from the left.
I doubt it would come as easy if they have to actually read and understand the code.Whereas when I use "Go to slot " it manages automatically.
Well, this feature is handy but also a bit dangerous as a rename of function or the widget will break the connection for good. Also turned out that doing the connects in the
constructor allowed quite easy to jump to a function as its then quite clear which button/widget goes where.