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
| Constant | Value | Description |
|---|---|---|
| Qt::PlainText | 0 | 纯文本字符串 |
| Qt::RichText | 1 | 文本字符串被解释为富文本字符串。 |
| Qt::AutoText | 2 | 如果 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):
本文详细介绍了Qt中的 QLabel 控件的各种属性,如文本(text)、格式(textFormat)、像素图(pixmap)、对齐(alignment)、换行(wordWrap)等,并提供了相应的接口函数和常量。了解这些属性有助于优化UI设计和实现丰富的文本呈现效果。
752

被折叠的 条评论
为什么被折叠?



