I had a QWidget displaying a complex layout containing many widgets.
The code was approximately:
#ifndef Q_OS_MAC
outerLayout->addWidget(newMenu);
#endif
h_layout->setContentsMargins(0,0,0,0);
h_layout->setSpacing(0);
h_layout->addWidget(newDocumentsDocklet);
h_layout->addWidget(newEditorsDocklet);
outerLayout->addLayout(h_layout);
window->setLayout(outerLayout);
#ifndef Q_OS_MAC
QMenuBar *newMenu = createMenus();
outerLayout->addWidget(newMenu);
#endif
QHBoxLayout * h_layout = new QHBoxLayout;
h_layout->setContentsMargins(0,0,0,0);
h_layout->setSpacing(0);
h_layout->addWidget(newDocumentsDocklet);
h_layout->addWidget(newEditorsDocklet);
outerLayout->addLayout(h_layout);
window->setLayout(outerLayout);
To copy to clipboard, switch view to plain text mode
This is the result:
01MCm.png
Unfortunately, when I changed my h_layout from QHBoxLayout to QSplitter, the QMenuBar changed its height. I don't understand if this is a bug, as I thought the the QMenuBar had a specific height.
The new code looks like this:
#ifndef Q_OS_MAC
outerLayout->addWidget(newMenu);
#endif
h_layout->setOrientation(Qt::Horizontal);
h_layout->addWidget(newDocumentsDocklet);
h_layout->addWidget(newEditorsDocklet);
outerLayout->addWidget(h_layout);
window->setLayout(outerLayout);
#ifndef Q_OS_MAC
QMenuBar *newMenu = createMenus();
outerLayout->addWidget(newMenu);
#endif
QSplitter * h_layout = new QSplitter;
h_layout->setOrientation(Qt::Horizontal);
h_layout->addWidget(newDocumentsDocklet);
h_layout->addWidget(newEditorsDocklet);
outerLayout->addWidget(h_layout);
window->setLayout(outerLayout);
To copy to clipboard, switch view to plain text mode
This is the new rendering:
KCU9e.png
Is somebody able to help me understand why this has happened? And a way to solve this?
Bookmarks