QLayout子类布局时会自动占满全部的空间,和一般需要多大空间占多大空间的要求不符合,很烦人。

案例:

本来一个容器简单的放几个组件会剩余很大的空间,就那么剩余就好。

结果呢?把全部的空间都占据了,然后组件之间还有很多的空白。

解决方案:

指定对齐方式:QLayout.setAlignment( Qt.AlignTop )

void QBoxLayout::addWidget(QWidget * widget, int stretch = 0, Qt::Alignment alignment = 0)

Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.

The stretch factor applies only in the direction of the QBoxLayout, and is relative to the other boxes and widgets in this QBoxLayout. Widgets and boxes with higher stretch factors grow more.

If the stretch factor is 0 and nothing else in the QBoxLayout has a stretch factor greater than zero, the space is distributed according to the QWidget:sizePolicy() of each widget that's involved.

The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.

QLayout布局时自动占满全部的空间。的更多相关文章

  1. 有一台机器,上面有m个储存空间。然后有n个请求,第i个请求计算时需要占 R[i]个空间,储存计算结果则需要占据O[i]个空间(据O[i]个空间(其中O[i]<R[i])。问怎么安排这n个请求的顺序,使

    有一台机器,上面有m个储存空间.然后有n个请求,第i个请求计算时需要占 R[i]个空间,储存计算结果则需要占据O[i]个空间(据O[i]个空间(其中O[i]<R[i]).问怎么安排这n个请求的顺 ...

  2. 换了XCode版本之后,iOS应用启动时不占满全屏,上下有黑边

    原因是没有Retina4对应的启动图片,解决方法很简单,就是把Retina4对应的图片给补上就只可以了

  3. Android ScrollView 子控件不占满的问题

    经常碰到很笨的 ScrollView的子控件无法占满 ScrollView 的空间的问题. 其实只需要加一行,android:fillViewport="true" 但不加上这行就 ...

  4. 让ThreadPoolExecutor的workQueue占满时自动阻塞submit()方法

    public class BlockingSubmitExecutor { private ExecutorService executor = new ThreadPoolExecutor(2, 2 ...

  5. css3 的 calc()函数在布局中的使用----头部高度固定,页面正好占满一屏

    最近项目遇到一个布局需求,头部高度固定,页面需要刚好占满一屏幕. 如下示意图: 方法:使用calc .wrap{ position: relative; margin-left: 24px; marg ...

  6. Android RelativeLayout wrap_content 而且 child view 使用 layout_alignParentBottom 时 RelativeLayout 高度会占满屏幕

    Android RelativeLayout wrap_content 而且 child view 使用 layout_alignParentBottom 时 RelativeLayout 高度会占满 ...

  7. 【Android 应用开发】Android中使用ViewPager制作广告栏效果 - 解决ViewPager占满全屏页面适配问题

    . 参考界面 : 携程app首页的广告栏, 使用ViewPager实现        自制页面效果图 : 源码下载地址: http://download.csdn.net/detail/han1202 ...

  8. Android中使用ViewPager制作广告栏效果 - 解决ViewPager占满全屏页面适配问题

    . 参考界面 : 携程app首页的广告栏, 使用ViewPager实现        自制页面效果图 : 源码下载地址: http://download.csdn.net/detail/han1202 ...

  9. (iOS)使用auto layout进行复杂布局时,UILabel的相关trick

    本文转载至 http://blog.csdn.net/madongchunqiu/article/details/47960745  本文首发于CSDN:http://blog.csdn.net/ma ...

随机推荐

  1. jQuery 复选框全选/取消全选/反选

    jQuery实现的复选框全选/取消全选/反选及获得选择的值. 完整代码: <!DOCTYPE html> <html> <head> <script type ...

  2. 【Android】7.3 GridLayout(网格布局)

    分类:C#.Android.VS2015: 创建日期:2016-02-10 一.简介 Android 4.0(API 14)开始提供的GridLayout布局使用虚细线将布局划分为行.列和单元格,也支 ...

  3. 每日英语:Burning Question / Does Reading In Dim Light Hurt Your Eyes?

    Mom always told us we'd go blind if we read in the dark. Does science back her up? Jim Sheedy, a doc ...

  4. SwitchOmega的详细配置——for Windows

    必看 先下载Shadowsocks客户端进行相应配置,然后只要对SwitchOmega 进行新建情景模式后简单配置即可. 本文不谈如何安装SwitchOmega只谈如何配置SwitchOmega 不会 ...

  5. mybatis中如果存在参数不再实体中的是如何处理

    <select id="queryMapByType" parameterType="int" resultType="my.geomap.VO ...

  6. 【C#】访问泛型中的List列表数据

    光看标题的确不好说明问题,下面描述一下问题场景: 已知后端自定义的返回的Json数据结构如下: response: { "message": "返回成功", & ...

  7. valgrind: failed to start tool 'memcheck' for platform 'amd64-linux

    valgrind运行错误 问题描述 valgrind运行时,无法找到相关工具文件,具体报错如下 valgrind: failed to start tool 'memcheck' for platfo ...

  8. java资料——数据结构(转)

    数据结构 (计算机存储.组织数据方式)                                                                            数据结构是 ...

  9. javascript那些不应该忽视的细节

    1.null与Object.prototype使用typeof操作符结果都是object,但他们都不是Object的实例. typeof null // object null instanceof ...

  10. 华为console口配置

    c.单击“Connect”,终端界面会出现如下显示信息,提示用户配置登录密码.设备缺省用户名为admin,密码为Admin@huawei.(以下显示信息仅为示意) user-interface con ...