Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.2
-
None
-
macOS 12
Description
I found that layouts inherited from QBoxLayout have artificial margins which are not affected/removable by setting setContentsMargins().
Check the following code:
#include <QApplication> #include <QPushButton> #include <QVBoxLayout> #include <QWidget> int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget w; auto layout = new QVBoxLayout(); w.setLayout(layout); auto layout2 = new QVBoxLayout(); layout2->setContentsMargins(0, 0, 0, 0); layout->addLayout(layout2); auto b1 = new QPushButton("B1"); layout2->addWidget(b1); auto b2 = new QPushButton("B2"); layout2->addWidget(b2); auto b3 = new QPushButton("B3"); layout->addWidget(b3); auto b4 = new QPushButton("B4"); layout->addWidget(b4); w.show(); return a.exec(); }
There are four buttons B1-B4. The first two are in an inner layout, which has contents margins equal to 0. The other two are in outer layout. On Windows and Linux, this shows a widget with four equal and equally spaced buttons.
On macOS however this shows buttons B1 and B2 somehow smaller and with spacing between B2 and B3 being bigger than other spacings. See the attached picture.
This is so surprising behaviour that I consider this to be a bug.
I also found that there are some #ifdef Q_OS_MAC in qboxlayout.cpp which I blame to be at fault. I think that layouting should be platform-agnostic.
Attachments
Issue Links
- relates to
-
QTBUG-138262 Add ability to disable QBoxLayout effective margins on macOS
-
- Reported
-