QLabel.setAlignment (self, Qt.Alignment)

下面查看Qt.Alignment

Qt.AlignmentFlag

This enum type is used to describe alignment. It contains horizontal and vertical flags that can be combined to produce the required effect.

The TextElideMode enum can also be used in many situations to fine-tune the appearance of aligned text.

The horizontal flags are:

Constant Value Description
Qt.AlignLeft 0x0001 Aligns with the left edge.
Qt.AlignRight 0x0002 Aligns with the right edge.
Qt.AlignHCenter 0x0004 Centers horizontally in the available space.
Qt.AlignJustify 0x0008 Justifies the text in the available space.

The vertical flags are:

Constant Value Description
Qt.AlignTop 0x0020 Aligns with the top.
Qt.AlignBottom 0x0040 Aligns with the bottom.
Qt.AlignVCenter 0x0080 Centers vertically in the available space.

You can use only one of the horizontal flags at a time. There is one two-dimensional flag:

Constant Value Description
Qt.AlignCenter AlignVCenter | AlignHCenter Centers in both dimensions.

You can use at most one horizontal and one vertical flag at a time. Qt.AlignCenter counts as both horizontal and vertical.

Three enum values are useful in applications that can be run in right-to-left mode:

Constant Value Description
Qt.AlignAbsolute 0x0010 If the widget's layout direction is Qt.RightToLeft (instead of Qt.LeftToRight, the default), Qt.AlignLeft refers to the right edge and Qt.AlignRight to the left edge. This is normally the desired behavior. If you want Qt.AlignLeft to always mean "left" and Qt.AlignRight to always mean "right", combine the flag with Qt.AlignAbsolute.
Qt.AlignLeading AlignLeft Synonym for Qt.AlignLeft.
Qt.AlignTrailing AlignRight Synonym for Qt.AlignRight.

Masks:

Constant Value
Qt.AlignHorizontal_Mask AlignLeft | AlignRight | AlignHCenter | AlignJustify | AlignAbsolute
Qt.AlignVertical_Mask AlignTop | AlignBottom | AlignVCenter

Conflicting combinations of flags have undefined meanings.

The Alignment type is a typedef for QFlags<AlignmentFlag>. It stores an OR combination of AlignmentFlag values.

简单示范:

self.label.setAlignment(Qt.AlignLeft)

设置label中的对齐方式的更多相关文章

  1. [Swift通天遁地]二、表格表单-(12)设置表单文字对齐方式以及自适应高度的文本区域TextArea

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  2. IOS开发中设置控件内容对齐方式时容易混淆的几个属性

    IOS开发中四个容易混淆的属性: 1. textAligment : 文字的水平方向的对齐方式 1> 取值 NSTextAlignmentLeft      = 0,    // 左对齐 NST ...

  3. C语言中内存对齐方式

    一.什么是对齐,以及为什么要对齐: 1. 现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定变量的时候经常在特定的内存地址访问, ...

  4. vertical-align 属性设置元素的垂直对齐方式。

     值 描述 baseline 默认.元素放置在父元素的基线上. sub 垂直对齐文本的下标. super 垂直对齐文本的上标 top 把元素的顶端与行中最高元素的顶端对齐 text-top 把元素的顶 ...

  5. UIButton设置UIControlContentHorizontalAlignment调整文字对齐方式

    UIButton 继承自UIControl,所以可以对UIControlContentHorizontalAlignment进行设置 btn.setImage(UIImage.init(named: ...

  6. iOS 设置Label中特定的文字大小和颜色

    直接上代码: _price = @"27"; NSMutableAttributedString *attributedString = [[NSMutableAttributed ...

  7. 通过代码设置button中文字的对齐方式

    // button.titleLabel.textAlignment = NSTextAlignmentLeft; 这句无效 button.contentHorizontalAlignment = U ...

  8. JQuery EasyUI之DataGrid列名和数据列分别设置不同对齐方式(转)

    需求如下 现有数据列三列 Name,Age,CreateDate 数据 张三,18,2000-12-09 :12:34:56 李四,28,2000-12-09 :12:34:56 王麻子,38,200 ...

  9. 认识CSS中css引入方式、选择器、文本样式设置以及显示模式

    前端之HTML.CSS(三) CSS CSS-Cascading Styles Sheets,层叠样式表.用于网页的表现,主要用于布局和修饰网页. CSS引入方式 CSS的三种引入方式:行内样式,内部 ...

随机推荐

  1. eclipse 模版的使用

    输入:s,然后利用快捷提示键(alt+/)高速的打出:System.out.println(""); 这样能够节省不少时间,使用了三个按键,却打出了这么多的字.事实上,这个功能是利 ...

  2. 算法笔记_078:蓝桥杯练习 最大最小公倍数(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 问题描述 已知一个正整数N,问从1~N中任选出三个数,他们的最小公倍数最大可以为多少. 输入格式 输入一个正整数N. 输出格式 输出一个整数,表示你 ...

  3. 使用PHP和GZip压缩网站JS/CSS文件加速网站访问速度

    使用PHP和GZip压缩网站JS/CSS文件加速网站访问速度 一些泛WEB 2.0网站为了追求用户体验,可能会大量使用CSS和JS文件.这就导致在服务器带宽一定的情况下,多用户并发访问速度变慢.如何加 ...

  4. [IOS A] - 一些开源类库

    因 为iOS SDK相对比较底层,所以开发者就得受累多做一些体力活.不过幸运的是,有很多第三方的类库可以用来简化很多不必要的工作.笔者整理了一下在本人学习过程 中用到的一些比较有用Objective- ...

  5. STL容器分析--set

    STL 对这个序列可以进行查找,插入删除序列中的任意一个元素,而完成这些操作的时间同这个序列中元素个数的对数成比例关系,并且当游标指向一个已删除的元素时,删除操作无效.而一个经过更正的和更加实际的定义 ...

  6. [Android进阶]Binder学习(初始篇)

    Android中Binder学习(初始篇) 本篇博客学习自侯亮的博客.地址为: 红茶一杯话Binder 1 什么是Binder? 简单地说.Binder是Android平台上的一种跨进程交互技术. 该 ...

  7. 本体论与OWL

    http://semanticweb.org/wiki/Main_Page.html http://owl.man.ac.uk/documentation.shtml  https://zh.wiki ...

  8. js的常见函数

    var n=0.0145; n.toFixed(2);//保留两位小数 n.lastIndexOf('a');//检索字符串最后出现的位置 n.indexof("h");//检索字 ...

  9. asp.net mvc5 配置自定义路径

    首先配置路由文件,默认页是第一个路由的配置: using System; using System.Collections.Generic; using System.Linq; using Syst ...

  10. Atitit.遍历图像像素点rgb java attilax总结

    Atitit.遍历图像像素点rgb java attilax总结 1. 遍历像素点 1 2. 提取一行 1 3. Rgb分量提取 2 4. 其他读取像素 3 5. --code 5 6. 参考 6 1 ...