Set content margins from stylesheet

非 Y 不嫁゛ 提交于 2019-12-12 11:07:40

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/13633203/set-content-margins-from-stylesheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!