本页内容

Label QML Type

采用继承字体的样式化文本标签。更多...

Import Statement: import QtQuick.Controls
Inherits:

Text

属性

详细说明

Label 扩展了Text ,增加了样式设置和font 继承功能。默认颜色和字体取决于具体样式。Label 还可以包含一个视觉元素background 。

带有样式设置的文本标签

Label {
    text: "Label"
}

您可以使用Text 的属性来按需更改文本的外观:

Label {
    text: "Hello world"
    font.pixelSize: 22
    font.italic: true
}

另请参阅 “自定义标签”。

属性文档

background : Item

该属性用于存储背景项。

注意:如果 未显式指定背景项的大小,它将自动采用控件的大小。在大多数情况下,无需为背景项指定宽度或高度。

另请参阅 “自定义标签”。

bottomInset : real [since QtQuick.Controls 2.5 (Qt 5.12)]

该属性用于设置背景的底部内距。

该属性在 QtQuick.Controls 2.5(Qt 5.12)中引入。

另请参阅 Control Layout 和topInset 。

implicitBackgroundHeight : real [read-only, since QtQuick.Controls 2.5 (Qt 5.12)]

该属性存储隐式背景高度。

其值等于background ? background.implicitHeight : 0 。

该属性在 QtQuick.Controls 2.5(Qt 5.12)中引入。

另请参阅 implicitBackgroundWidth 。

implicitBackgroundWidth : real [read-only, since QtQuick.Controls 2.5 (Qt 5.12)]

该属性存储隐式背景宽度。

其值等于background ? background.implicitWidth : 0 。

该属性在 QtQuick.Controls 2.5(Qt 5.12)中引入。

另请参阅 implicitBackgroundHeight 。

leftInset : real [since QtQuick.Controls 2.5 (Qt 5.12)]

该属性用于设置背景的左内边距。

该属性在 QtQuick.Controls 2.5(Qt 5.12)中引入。

另请参阅 Control Layout 和rightInset 。

rightInset : real [since QtQuick.Controls 2.5 (Qt 5.12)]

该属性用于设置背景的右内边距。

该属性在 QtQuick.Controls 2.5(Qt 5.12)中引入。

另请参阅 Control Layout 和leftInset 。

topInset : real [since QtQuick.Controls 2.5 (Qt 5.12)]

该属性用于设置背景的顶部内边距。

该属性在 QtQuick.Controls 2.5(Qt 5.12)中引入。

另请参阅 Control Layout 和bottomInset 。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.