I have a QMainWindow
and I have inserted mdiArea
in the main window.
You must first see the following image:
As you seen the gray area is mdiArea
and the spaces(margin) that between main window and mdiArea
are what I want to remove it.
I have used setContentsMargins
function, but does not do anything.
How can I remove these spaces ?
I want to be like the following image:
QMainWindow
has a central widget that has a layout. The layout you use on QMainWindow
is should be used upon its central widget instead. Hence you have to call
QWidget* QMainWindow::centralWidget()
first,
so you can get the central widget first and then use
void QLayout::setContentsMargins(int left, int top, int right, int bottom)
to adjust its layout. The diagram below comes from Qt's documentation.
Creating a main window without a central widget is not supported. You must have a central widget even if it's just a placeholder.
For example, you could have the following in QMainWindow
's constructor:
centralWidget()->layout()->setContentsMargins(0, 0, 0, 0);
statusBar()->hide();
ui->mainToolBar->hide();
The status bar and the tool bar have been hidden, in order to remove as much blank space as possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With