Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to add a row of widgets army run time
JosueKnox last edited by JosueKnox
I am new to QT, but I am an experienced programmer. I am trying to create a QT app that will contain a combo box and a stacked widget all on one row. After executing the app I would like to create additional rows like the first one as needed. Is this something I can do with either QT creator or designer with UI files. I figure I can code this up, but I want to use the ease of the GUI. What would be the best approach? https://shareit.onl/ https://appvn.onl/
Hi and welcome to devnet,
You can build the base widget with designer but the rest of the logic will need to be coded anyway. Therefore I would say that, in this case, you can as well do the whole thing in code.
Since you experienced, allow me a few pointers.
Using an UI files is close to using code anyway.
The UI file is an XML file that get processed by the uic tool and c++ code is generated.
You can find it in the setupUI function
Therefore it has no overhead or other price to pay.
So when starting out, its very useful to design complex layouts
using UI files as its less involving than directly in code.
(if you are not completely alien to wysiwyg editing )
So in many cases, setting up the Widgets in Designer and adding code for the dynamic part is
helpful to reduce the code you have to look over to see the actual logic.
Later when you feel more at home in Qt, simple forms and dialogs are handy to create from pure code.
Also Creator/Designer allows a method called promotion that allows you to use a custom widget in the design and
when app is run is the actual custom widgets. Combined with dynamic properties it allows for integration in
a manner not normally possible for a compiled language framework.
That said, some do liek having it all in code better and there really is not one correct answer.
Personally i like the mixed approach as UI files allow other team members to do a little GUI programming as its
easy to drag a new button to a form. However, reading tons of code to understand where the statements goes is another story, and you also feel that some years later when you come back to an app to add features etc.