Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I insert a widget into a mainwindow generated by Qt designer?

Tags:

qt

nokia

qwidget

I have a Main window build with Qt Designer and I also have a widget built with Qt designer (both in a separate ui file). How can I instantiate my widget into my mainwindow at runtime?

like image 797
yan bellavance Avatar asked Dec 18 '25 00:12

yan bellavance


1 Answers

The easiest way (using Designer) is to open your main window, drag a QWidget into it, and position/name the QWidget like you would your custom widget. Once that is done, right-click on the QWidget, and select Promote to.... A dialog will show up with the widgets it can be promoted to. At the bottom of that dialog, you can add a new widget for promotion. Type in the class name and include file information, and add that widget. Then select the entry in the list, and click the Promote button.

At the end of this process, you should be able to recompile, and your custom widget will be where you placed it in the main window.

like image 134
Caleb Huitt - cjhuitt Avatar answered Dec 19 '25 20:12

Caleb Huitt - cjhuitt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!