1
votes

I am trying to promote the top level QWidget into a derived MyWidget class using the "promote to" menu in Qt Designer.

For that, i have defined the promotion with the "promoted widgets.." menu.

I have also add a child QWidget (in violet) to the top level QWidget and i was able to promote into it into MyWidget using the "promote to" option, that appear after a right click in the object inspector. (as shown in the picture)

enter image description here

But for the top level QWidget, the right click don't give access to the "promote to" menu and i have the same problem with a QFrame.

Is it possible to do that with Qt Designer ?

Thank you.

1
In a way you can say that the top Level is already promoted since you are using a custom widget, in your case Widget. - eyllanesc
Actually, i understand why the root widget is a special case. The uic generates a class with the name of this widget ( class Ui::Widget ) and the child widgets are public members of this class and instancianted in the setupUi function. Then using Qt's single inheritance approach, it might be easier to write a derived class of QWidget ( MyWidget ) and apply the setupUi function on it. So i guess it doesn't make sense to do that inside Qt Designer. - Fryz

1 Answers

2
votes

No, you can't promote top Widget in Designer. But you can do it manually. Simply open ui file in text editor and make necessary changes to the top level widget. Which changes you will need you can see in your child widget defenition. Just copypaste needed fields and values.