Palette QML Type

Contains color groups for each QML item state. 更多...

导入语句: import QtQuick

特性

详细描述

调色板由 3 个颜色组组成: active , 被禁用 ,和 inactive active color group is the default group: its colors are used for other groups if colors of these groups aren't explicitly specified.

In the following example, color is applied for all color groups:

ApplicationWindow {
    palette.buttonText: "salmon"
    ColumnLayout {
        Button {
            text: qsTr("Disabled button")
            enabled: false
        }
        Button {
            text: qsTr("Enabled button")
        }
    }
}
					

It means that text color will be the same for both buttons.

In the following example, colors will be different for enabled and disabled states:

ApplicationWindow {
    palette.buttonText: "salmon"
    palette.disabled.buttonText: "lavender"
    ColumnLayout {
        Button {
            text: qsTr("Disabled button")
            enabled: false
        }
        Button {
            text: qsTr("Enabled button")
        }
    }
}
					

It is also possible to specify colors like this:

palette {
    buttonText: "red"
    button: "khaki"
    disabled {
        buttonText: "lavender"
        button: "coral"
    }
}
					

This approach is especially convenient when you need to specify a whole palette with all color groups; but as with the other cases above, the colors that are not specified are initialized from SystemPalette , or potentially the Qt Quick Controls style , if one is in use.

注意: Some Controls styles use some palette colors, but many styles use independent colors.

另请参阅 Window::palette , Item::palette , Popup::palette ,和 SystemPalette .

特性文档编制

active : ColorGroup

The Active group is used for windows that are in focus.

另请参阅 QPalette::Active .


被禁用 : ColorGroup

The Disabled group is used for elements that are disabled for some reason.

另请参阅 QPalette::Disabled .


inactive : ColorGroup

The Inactive group is used for windows that have no keyboard focus.

另请参阅 QPalette::Inactive .