• 设置label中的对齐方式


    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:

    ConstantValueDescription
    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:

    ConstantValueDescription
    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:

    ConstantValueDescription
    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:

    ConstantValueDescription
    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:

    ConstantValue
    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)

  • 相关阅读:
    ASP.NET 2.0 解决了 CodeBehind 需要控件声明同步的问题
    Script# 把 C# 编译为 JavaScript
    我不懂 ASP.NET
    ASP.NET 是如何让 aspx 完全编译的呢?
    ASP.NET 设计优秀之处
    .NET 的灵魂是什么?
    初次使用Atlas JavaScript (Part 2 Web Service扩展)
    XNA Microsoft 平台的新游戏框架
    ViewState ASP.NET 的一个特有存储容器
    2 Ways Thinking In Ajax
  • 原文地址:https://www.cnblogs.com/daniaofighter/p/5713168.html
Copyright © 2020-2023  润新知