tags:

views:

380

answers:

2

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?

+1  A: 

Can't you use QMainWindow::setCentralWidget function?

Ariya Hidayat
+3  A: 

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.

Caleb Huitt - cjhuitt