Qt样式表 - 如何消除死空间 [英] Qt Stylesheets - how to remove dead space

查看:632
本文介绍了Qt样式表 - 如何消除死空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PySide创建一个简单的绘图应用程序,并且有一个死空间的问题。



如何使用样式表删除所有这些额外的填充或编程?
我已经尝试将QFrame的边距和填充设置为0,但效果不大。



我使用布局定位,我的小部件继承自QFrame并且通常包含其他小部件,如QTabWidget,QListWidget等。



(我已经避免使用QWidget,因为我相信这是不完全支持Qt样式) p>

下面是我的应用程序的屏幕截图,红线指出了我的问题死空间(底部的红线有点太长了 - 有一个状态栏)





任何想法?

解决方案

如果你对窗口小部件的背景进行着色, code> margin 或 padding 将更改间距和边距。这由布局控制。因此在您的布局集中:

  layout.setContentsMargins(0,0,0,0)
layout.setSpacing 0)

,所有空格都应该删除。不幸的是,这只能以编程方式而不是通过样式表。另请参见 Qt设置contentsMargins从样式表删除边距


I am creating a simple plotting application using PySide and have a problem with loads of dead space.

How can I remove all this extra padding using stylesheets (preferably) or programmatically? I've tried setting margins and padding on QFrame to 0, but with little effect.

I'm using layouts for positioning and my widgets inherit from QFrame and generally contain other widgets such as QTabWidget, QListWidget etc..

(I have avoided the use of QWidget as I believe this is not fully supported by Qt Stylesheets)

Below is a screenshot of my app, with red lines pointing out my problematic dead space (The bottom red line is a bit too long - there is a statusbar)

Any ideas?

解决方案

If you color the background of your widgets you see that no value for property margin or padding will change the spacing in between and the margin. This is controlled by the layout. Therefore in your layout set:

layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)

and all empty spaces should be gone. Unfortunately this can only be done programmatically and not by stylesheets. See also comments in Qt set contentsMargins from stylesheet and Qt remove margins

这篇关于Qt样式表 - 如何消除死空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆