Qt控件--QLabel

属性

在这里插入图片描述

Properties

alignment : Qt::Alignment
hasSelectedText : const bool
indent : int
margin : int
openExternalLinks : bool
pixmap : QPixmap
scaledContents : bool
selectedText : const QString
text : QString
textFormat : Qt::TextFormat
textInteractionFlags : Qt::TextInteractionFlags
wordWrap : bool

text

显示的文本。

text接口函数

QString text() const:获取文本
void setText(const QString &):设置显示的文本

textFormat

此属性保存标签的文本格式。

textFormat接口函数

Qt::TextFormat textFormat() const:获取文本的格式
void setTextFormat(Qt::TextFormat):设置文本的格式

enum Qt::TextFormat

ConstantValueDescription
Qt::PlainText0纯文本字符串
Qt::RichText1文本字符串被解释为富文本字符串。
Qt::AutoText2如果 Qt::mightBeRichText() 返回 true,则文本字符串被解释为 Qt::RichText,否则解释为 Qt::PlainText。

pixmap : QPixmap

此属性保存标签的像素图。

pixmap 接口函数

*const QPixmap pixmap() const:获取图像
void setPixmap(const QPixmap &):设置图像信息

scaledContents : bool

此属性保存标签是否将缩放其内容以填充所有可用空间。当启用并且标签显示像素图时,它将缩放像素图以填充可用空间。此属性的默认值为 false。

scaledContents接口函数

bool hasScaledContents() const:获取图像是否进行的缩放
void setScaledContents(bool):设置图像是否进行缩放

alignment : Qt::Alignment

设置水平或者垂直对齐。

alignment接口函数

Qt::Alignment alignment() const
void setAlignment(Qt::Alignment)

wordWrap:bool

此属性保存标签的自动换行策略否则它根本不会被包裹。默认情况下,自动换行是禁用的。

wordWrap接口函数

bool wordWrap() const
void setWordWrap(bool on)

margin : int

该属性保存边距的宽度边距是框架最里面的像素和内容的最外面的像素之间的距离。默认边距为 0。

margin接口函数

int margin() const:获取距离
void setMargin(int):设置距离

indent : int

此属性以像素为单位保存标签的文本缩进如果标签显示文本,如果alignment() 是Qt::AlignLeft,则缩进应用于左边缘。

indent 接口函数

int indent() const:获取缩进的方式
void setIndent(int):获取缩进的位置

openExternalLinks : bool

指定 QLabel 是否应使用 QDesktopServices::openUrl() 自动打开链接而不是发出 linkActivated() 信号。
Specifies whether QLabel should automatically open links using QDesktopServices::openUrl() instead of emitting the linkActivated() signal.
Note: The textInteractionFlags set on the label need to include either LinksAccessibleByMouse or LinksAccessibleByKeyboard.
The default value is false.
This property was introduced in Qt 4.2.
Access functions:

openExternalLinks 接口函数

bool openExternalLinks() const:获取是否可以外部链接
void setOpenExternalLinks(bool open):设置是否可以外部链接

textInteractionFlags : Qt::TextInteractionFlags

指定标签在显示文本时应如何与用户输入交互。

textInteractionFlags 接口函数

Qt::TextInteractionFlags textInteractionFlags() const
void setTextInteractionFlags(Qt::TextInteractionFlags flags)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值