How to remove margins of QLayout completely (Mac OS specific)

后端 未结 1 915
深忆病人
深忆病人 2021-01-16 14:02

Let me explain a simplified situation. In Qt Creator, create a QHBoxLayout containing a QPushButton and another QHBoxLayout which cont

相关标签:
1条回答
  • 2021-01-16 14:24

    This issue is only visible for several certain widgets (e.g QPushButton, QComboBox etc) on Mac OS.

    Setting Qt::WA_LayoutUsesWidgetRectattribute on those widgets would solve it:

    button->setAttribute(Qt::WA_LayoutUsesWidgetRect);
    

    Reference: QMacStyle: QPushButtons always have space below when in a QLayout

    A related issue with the same solution could be found here: Why is QHBoxLayout causing widgets to overlap?

    0 讨论(0)
提交回复
热议问题