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. jenkins 发送邮件模板

    jenkins 发送邮件模板 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...

  2. 使用VMware安装CentOS7步骤详情

    准备资料: CentOS-7-x86_64-Everything-1611 点击下载CentOS 对,资料就这些 第一步.  点击文件  再点击新建虚拟机 第二步 .点击完新建虚拟机之后会跳出一个窗口 ...

  3. markdown 语法简要备忘

    标题 # 一级标题 ## 二级标题 ### 三级标题 无序列表 前面加 - 或 * 即可变为 有序列表 直接用数字即可 1. 2. 3. 添加引用 > 图片与链接 插入链接与插入图片的语法很像, ...

  4. C++ new操作符详解

    一.new操作符的概念 我们通常讲的new是指的是new operator,其实还有另外两个概念,operator new 和 placement new. 1.new operator 我们在使用n ...

  5. nyoj228 士兵杀敌(5)插线问线

    士兵杀敌(五) 时间限制:2000 ms  |  内存限制:65535 KB 难度:5   描述 南将军麾下有百万精兵,现已知共有M个士兵,编号为0~M,每次有任务的时候,总会有一批编号连在一起人请战 ...

  6. ny220 推桌子

    推桌子 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 The famous ACM (Advanced Computer Maker) Company has rent ...

  7. PHP5.4新特性之上传进度支持Upload progress

    在PHP5.4版本当中给我们提供了好用的特性,上传进度的支持,我们可以配合Ajax动态获取SESSION当中的上传进度: 在使用这一特性之前,需要现在php.ini文件当中进行相应的设置:   1 2 ...

  8. html5 的localstorage

    /** * 向localStorage中设置数据 * @param key 字符串 * @param value 数组 */ function SetDataIntoLocalStorage(key, ...

  9. java 中的 ThreadLocal

    首先,ThreadLocal 不是用来解决共享对象的多线程访问问题的,一般情况下,通过ThreadLocal.set() 到线程中的对象是该线程自己使用的对象,其他线程是不需要访问的,也访问不到的.各 ...

  10. java图片截取组件ImageIO

    引用:http://blog.csdn.net/cdl2008sky/article/details/7775681 javax.imageio使用 ImageIO 类的静态方法可以执行许多常见的图像 ...