How to use widgets designed in UI designer?



  • Hi everyone,

    I am new to QT and i cannot find an answer to my question.
    I designed a custom dialog using "Add New">"Qt">"Qt Designer Form Class">"Dialog without Buttons".
    This custom dialog should have interchangable sections which I designed as well using "Add New">"Qt">"Qt Designer Form">"Widget".

    Now I would like to place the widgets into the Dialog. How can I do that?

    Thank you in advance,
    Raoul


  • Lifetime Qt Champion

    Hi and welcome to the forums.
    You can use the promotion feature.
    http://doc.qt.io/qt-5/designer-using-custom-widgets.html#promoting-widgets

    so in the Dialog, you place a plain widget and then right click and promote it.
    when you then run the app, it will be your widget.

    promotion is basically just Replace function where you tell it the real class name and what .h file to use.



  • @mrjj
    Thank you for your quick anser.
    So that means I should have used "Add New">"Qt">"Qt Designer Form Class">"Widget" instead of "Qt Designer Form"?


  • Lifetime Qt Champion

    @incam
    Yes if you want to use promotion, then you need the .h file.
    (from Qt Designer Form Class)

    The stand alone UI file can be used with
    http://doc.qt.io/qt-5/quiloader.html

    but you can not visually add it in another form as promotion does.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.