删除QWidget周围的额外间距 [英] Removing extra spacing around QWidget
本文介绍了删除QWidget周围的额外间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在QWidget周围删除多余的间距?
How to remove extra spacing around QWidget?
这是一个简单的例子。小部件的空间是灰色的你看,它的内容周围有一些空间(约0.3-0.4厘米)(图像,文本和按钮)。
Here's the simple example. The widget's space is grey; you see, there's some space (about 0.3-0.4 cm) around the content of it (image, text and button).
小部件的空间被
setAutoFillBackground(true);
QPalette pal(palette());
pal.setColor(QPalette::Background, QColor("#e5e5e5"));
setPalette(pal);
这是内容(通过运行 setStyleSheet(background-color:red)突出显示)
为整个小部件。
Here's the content (highlighted by running setStyleSheet( "background-color: red");
for the whole widget.
通过'删除额外的间距'我的意思是在内容周围删除约0.2-0.3厘米的灰色空间。
By 'removing extra spacing' I mean removing about 0.2-0.3 cm of grey space around content.
推荐答案
使用方法 setContentsMargins()
。
这篇关于删除QWidget周围的额外间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文