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 样式(如果正在使用)初始化。
注意: 有些 Controls 样式使用某些调色板颜色,但许多样式使用独立的颜色。
另请参阅 Window::palette,Item::palette,Popup::palette, 和SystemPalette 。
属性文档
active : ColorGroup |
活动组用于处于焦点的窗口。
另请参阅 QPalette::Active 。
disabled : ColorGroup |
Disabled 组用于因某种原因禁用的元素。
另请参见 QPalette::Disabled 。
inactive : ColorGroup |
非活动组用于没有键盘焦点的窗口。
另请参见 QPalette::Inactive 。
© 2025 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.