简体   繁体   English

QT 5.8从QGroupBox删除边距不起作用

[英]QT 5.8 Removing margins from QGroupBox not working

So i have a QGroupBox with a vertical layout inside of it. 所以我有一个带有垂直布局的QGroupBox
There is a QWidget container at top(blue). 顶部有一个QWidget容器(蓝色)。

I have used setContentsMargins(0,0,0,0) for both the QGroupBox and the QWidget container yet no matter what i do i cannot get the QWidget container to be at (0,0) in the top left of the groupbox. 我已经为QGroupBoxQWidget容器使用了setContentsMargins(0,0,0,0) ,但是无论我做什么,我都无法使QWidget容器位于groupbox左上方的(0,0) Ive marked in red the spacing i want to remove. 我已经用红色标记了我要删除的间距。

在此处输入图片说明

Those are QLayout margins. 这些是QLayout边距。 Set them to zero. 将它们设置为零。

You must algo set the margins of the layout to 0. Given a widget -- either your QGroupBox or your QWidget -- you can use the layout() method to access its underlying layout, and then set the margins on it. 您必须将布局的边距QGroupBox设置为0。给定一个小部件(您的QGroupBoxQWidget ,您可以使用layout()方法访问其基础布局,然后在其上设置边距。 Something like this: 像这样:

widget->layout()->setContentsMargins(0, 0, 0, 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM