Forms vs window + QVBoxLayout in Qt creator desktop applications
-
Hello, I'm just starting to use Qt Creator and find two ways to create desktop apps:
-
When I chose to create a new project, desktop app, Qt Creator creates an empty template for a form and it allows me to drag and drop widgets, move and resize them, etc.
-
When I open some built-in examples, I find some of the examples does not have a form itself but instantiate a QWidget and QVBoxLayout and then add all widgets programmatically.
Which ones of these is better or what are the pros and cons of them?
At first sight I find the forms with drag and drop functionality more friendly and easy to modify.
What is your opinion?
PS: In my case, portability Windows/Linux is important, in case this aspect does matter here.
-
-
@kweber said in Forms vs window + QVBoxLayout in Qt creator desktop applications:
Which ones of these is better or what are the pros and cons of them?
there is no really better / worse comparison.
If you like to design your GUI with Drag-n-Drop (=forms, =QtDesigner) then go with it. In the end the form definition is also translated to QWidget instances.I personally prefer to have "full control" over my code, so i create and compose the QWidgets myself.
-
Hi
I do most layouts using Designer and loads mostly data from code.
But you dont have to choose one way over the other.
The UI forms is converted to code ( see setupUI() )
so sometimes i use Designer to create a layout/setup and then use the code from my code as templates.
The main reason we like using UI files is that it allows the non UX developers to do a bit of GUI sometimes as its less involving to drag a new button to
a layout than reading heaps of setup code to find right spot.But basically, its more a matter of taste than anything technical . But there are things you need to do from code as designer cannot do it.