View Full Version : How do I add a QGridlayout in a QMainwindow?
Teuniz
14th February 2007, 09:26
I know how to add a QGridlayout in a QDialog but...
Is it possible to ad a QGridlayout to a QMainwindow without subclassing/inheriting QMainwindow?
How do I do this?
Tnx
jpn
14th February 2007, 09:28
Set the layout on a plain QWidget and set it as a central widget of the main window.
QWidget* widget = new QWidget(mainWindow);
widget->setLayout(gridLayout);
mainWindow->setCentralWidget(widget);
Teuniz
14th February 2007, 10:00
Tnx J-P Nurmi,
It works, but...
In the console I get the message:
QLayout: Attempting to add QLayout "" to QMainWindow "", which already has a layout
Despite this message it seems to work. Do you know I can prevent this message?
jpn
14th February 2007, 10:11
In the console I get the message:
QLayout: Attempting to add QLayout "" to QMainWindow "", which already has a layout
Despite this message it seems to work. Do you know I can prevent this message?
Do you pass the main window as a parent for the QGridLayout? That means same than setting the layout on the main window. So either don't pass any parent or pass the central widget as a parent for the grid layout.
Teuniz
14th February 2007, 10:18
Yep, you are right. Thanks a lot for your help J-P.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.