How do I add a QGridlayout in a QMainwindow?
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
Re: How do I add a QGridlayout in a QMainwindow?
Set the layout on a plain QWidget and set it as a central widget of the main window.
Code:
widget->setLayout(gridLayout);
mainWindow->setCentralWidget(widget);
Re: How do I add a QGridlayout in a QMainwindow?
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?
Re: How do I add a QGridlayout in a QMainwindow?
Quote:
Originally Posted by
Teuniz
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.
Re: How do I add a QGridlayout in a QMainwindow?
Yep, you are right. Thanks a lot for your help J-P.