QPalette:
Filter:
Classes | GUI > Accessories

QPalette

Set of colors used by the GUI
Location: NOT INSTALLED!

Description

QPalette is a set of colors that the GUI system uses to draw the views. The colors are organized into three color groups (active, inactive and disabled) used according to the state of the views drawn, and each group containing one color assigned to each of the various color roles (window, windowText, button, buttonText, etc.), used to draw distinct elements of the views. See Color roles and Color groups for details.

A palette can be assigned to the whole GUI using QtGUI: *palette, or to a particular view using View: -palette. Views will inherit a palette from their parent, and ultimately QtGUI, unless a palette is explicitly assigned to them. Moreover, when setting a palette on a view, it will be combined with the inherited one, overriding only those colors that have been explicitly set on the palette (see -hasColor). Hence, assigning a new and unmodified palette will reset all the colors to the inherited ones.

There are also two predefined palettes accessible using *light and *dark. The light palette is assigned to QtGUI by default on startup. Should you wish to use a palette that matches the color scheme used natively on your platform, you can access such palette using *system.

If you wish to design your own palette, it is most convenient to use *auto, which will automatically derive a palette from only two colors, and then modify the details as you see fit.

Note that in Qt GUI most color-related methods of views (like Window: -background, Slider: -knobColor, etc.) actually modify the view's palette.

Class Methods

.new

Instantiates a new palette, equivalent to the global palette assigned to QtGUI. All colors are considered to not be set (see -hasColor).

.auto

Instantiates a new palette, with colors automatically derived from the given colors for 'button' and 'window' color roles. All colors are considered to be set (see -hasColor).

Arguments:

buttonColor

The Color assigned to the button role.

windowColor

The Color assigned to the window role.

.light

A predefined palette using light colors. All colors are considered to be set (see -hasColor).

.dark

A predefined palette using dark colors. All colors are considered to be set (see -hasColor).

.system

The native system palette. All colors are considered to be set (see -hasColor).

Inherited class methods

Instance Methods

.color

Returns the color assigned to a color role within a color group.

Arguments:

role

A symbol among Color roles.

group

A symbol among Color groups, or nil, in which case the current color group is used.

.setColor

Assigns a color to a color role within a color group.

Arguments:

color

A Color.

role

A symbol among Color roles.

group

A symbol among Color groups, or nil, in which case the color will be assigned to all groups.

.hasColor

Whether the color belonging to a color role and group has been set on this QPalette instance.

When setting a palette on a view, only colors for which this methods returns true will be changed, others will be inherited from the parent view (or QtGUI if this view has no parent).

Arguments:

role

A symbol among Color roles.

group

A symbol among Color groups.

.window

Convenience method to get or set the color for the 'window' role.

.windowText

Convenience method to get or set the color for the 'windowText' role.

.button

Convenience method to get or set the color for the 'button' role.

.buttonText

Convenience method to get or set the color for the 'buttonText' role.

.base

Convenience method to get or set the color for the 'base' role.

.baseText

Convenience method to get or set the color for the 'baseText' role.

.highlight

Convenience method to get or set the color for the 'highlight' role.

.highlightText

Convenience method to get or set the color for the 'highlightText' role.

Inherited instance methods