Palette QML Type
包含每个 QML 项状态的颜色组。更多...
| Import Statement: | import QtQuick |
| Inherits: |
属性
详细说明
一个调色板由三个颜色组组成:active 、disabled 和inactive 。active 颜色组是默认组:如果其他组未显式指定颜色,则会使用该组的颜色。
在下面的示例中,颜色被应用于所有颜色组:
ApplicationWindow {
palette.buttonText: "salmon"
ColumnLayout {
Button {
text: qsTr("Disabled button")
enabled: false
}
Button {
text: qsTr("Enabled button")
}
}
}这意味着这两个按钮的文本颜色将相同。
在下面的示例中,启用和禁用状态下的颜色将不同:
ApplicationWindow {
palette.buttonText: "salmon"
palette.disabled.buttonText: "lavender"
ColumnLayout {
Button {
text: qsTr("Disabled button")
enabled: false
}
Button {
text: qsTr("Enabled button")
}
}
}也可以像这样指定颜色:
palette {
buttonText: "red"
button: "khaki"
disabled {
buttonText: "lavender"
button: "coral"
}
}当需要为所有颜色组指定整套调色板时,这种方法尤为方便;但与上述其他情况一样,未指定的颜色将从SystemPalette 初始化,或者如果启用了Qt Quick Controls 样式,则可能从该样式中获取。
注意:某些 控件样式会使用调色板中的颜色,但许多样式使用独立的颜色。
另请参阅 Window::palette 、Item::palette 、Popup::palette 以及SystemPalette 。
属性文档
active : ColorGroup
“Active”组用于当前处于焦点状态的窗口。
另请参阅 QPalette::Active 。
disabled : ColorGroup
“Disabled”组用于标记因某种原因被禁用的元素。
另请参阅 QPalette::Disabled 。
inactive : ColorGroup
“非活动”组用于没有键盘焦点的窗口。
另请参阅 QPalette::Inactive 。
© 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.