LucaDanieli
27th January 2017, 16:12
I had a QWidget displaying a complex layout containing many widgets.
The code was approximately:
#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);
This is the result:
12302
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
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);
This is the new rendering:
12303
Is somebody able to help me understand why this has happened? And a way to solve this?
The code was approximately:
#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);
This is the result:
12302
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
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);
This is the new rendering:
12303
Is somebody able to help me understand why this has happened? And a way to solve this?