PDA

View Full Version : How to convert a QWidget into a QMainWindow



jezz
16th September 2010, 12:56
Hi, I created a QWidget with controls in it. But now I need to put a menu into it, but how to convert it to a QMainWindow easily, without creating another form and paste the controls into it?

I tried to modify the ui file and changed the QWidget to QMainWindow, but the Designer complained when it open the file.

Thanks.

Zlatomir
16th September 2010, 13:00
You don't need to convert your QWidget into a QMainWindow.
You can create a new QMainWindow and use it's setCentralWidget() (http://doc.trolltech.com/4.6/qmainwindow.html#setCentralWidget) member function to make your widget appear in the main window.

jezz
16th September 2010, 13:06
You don't need to convert your QWidget into a QMainWindow.
You can create a new QMainWindow and use it's setCentralWidget() (http://doc.trolltech.com/4.6/qmainwindow.html#setCentralWidget) member function to make your widget appear in the main window.
Thanks, but I would like everything to be in one file, since they are all related.
Nice to know this tip though, will be using it one day.