Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 540
Ben Avatar asked Nov 29 '12 19:11

Ben


2 Answers

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.

like image 135
Trilarion Avatar answered Sep 21 '22 02:09

Trilarion


It is not possible to set a stylesheet for a QLayout, use a QWidget instead, in which you will set a layout. Then, you can set the margin and/or padding of your widget with stylesheet to match you needs.

like image 42
Kévin Renella Avatar answered Sep 18 '22 02:09

Kévin Renella