Search code examples
qtstylesheetmarginsqlayout

Set content margins from stylesheet


I'm struggling to set content margins to zero from QLayout objects in Qt with a stylesheet. I can remove them with QLayout::setContentsMargins(0, 0, 0, 0) but I would prefer to do it from stylesheet.


Solution

  • As of now this cannot be achieved. Use

    QLayout::setContentsMargins(0, 0, 0, 0)
    

    and

    QLayout::setSpacing(0)
    

    if you also want to eliminate the space between widgets.

    See also this bug report Stylesheet controls for QLayout objects which is unresolved so far.