View Full Version : Adding a Layout to QMainWindow

5th June 2010, 23:10
Alright, I'm a little new to Qt....

I have a QGridLayout with all of my content in it.. How could I apply it to a QMainWindow?

Thanks :)

6th June 2010, 00:08
QMainWindow has a setLayout(QLayout*) member function.

Or alternate way is to use QWidget with parent 0 as a main window, and pass the pointer as a parameter to the creation of layout (or use setLayout(...))
or add the widget, as central widget for QMainWindow, with setCentralWidget(QWidget*);

7th June 2010, 07:25
QMainWindow needs a central widget. So you can set your layout to a QWidget, and set it as centralWidget of the QMainWindow.