Struct rute::auto::palette::Palette

source ·
pub struct Palette<'a> { /* private fields */ }
Expand description

Notice these docs are heavy WIP and not very relevent yet

A palette consists of three color groups: Active, Disabled, and Inactive. All widgets in Qt contain a palette and use their palette to draw themselves. This makes the user interface easily configurable and easier to keep consistent.

If you create a new widget we strongly recommend that you use the colors in the palette rather than hard-coding specific colors.

The color groups:

  • The Active group is used for the window that has keyboard focus.
  • The Inactive group is used for other windows.
  • The Disabled group is used for widgets (not windows) that are disabled for some reason.

Both active and inactive windows can contain disabled widgets. (Disabled widgets are often called inaccessible or grayed out .)

In most styles, Active and Inactive look the same.

Colors and brushes can be set for particular roles in any of a palette’s color groups with setColor() and setBrush(). A color group contains a group of colors used by widgets for drawing themselves. We recommend that widgets use color group roles from the palette such as and rather than literal colors like or . The color roles are enumerated and defined in the ColorRole documentation.

We strongly recommend that you use the default palette of the current style (returned by QGuiApplication::palette()) and modify that as necessary. This is done by Qt’s widgets when they are drawn.

To modify a color group you call the functions setColor() and setBrush(), depending on whether you want a pure color or a pixmap pattern.

There are also corresponding color() and brush() getters, and a commonly used convenience function to get the ColorRole for the current ColorGroup: window(), windowText(), base(), etc.

You can copy a palette using the copy constructor and test to see if two palettes are identical using isCopyOf().

QPalette is optimized by the use of implicit sharing

so it is very efficient to pass QPalette objects as arguments.

Warning: Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for both the Windows Vista and the MacOS styles.

See also: [Application::set_palette] Widget::set_palette Color

Licence

The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.

Implementations

Swaps this palette instance with other. This function is very fast and never fails.

Returns the palette’s current color group.

Set the palette’s current color group to cg.

Overloads Returns the color that has been set for the given color role in the current ColorGroup.

See also: [brush()] ColorRole

Returns the color in the specified color group, used for the given color role.

See also: [brush()] [set_color()] ColorRole

Overloads Returns the brush that has been set for the given color role in the current ColorGroup.

See also: [color()] [set_brush()] ColorRole

Returns the brush in the specified color group, used for the given color role.

See also: [color()] [set_brush()] ColorRole

Overloads Sets the color used for the given color role, in all color groups, to the specified solid color.

See also: [brush()] [set_color()] ColorRole

Sets the color in the specified color group, used for the given color role, to the specified solid color.

See also: [set_brush()] [color()] ColorRole

Sets a the group at cg. You can pass either brushes, pixmaps or plain colors for windowText, button, light, dark, mid, text, bright_text, base and window.

See also: Brush

Overloads Sets the color used for the given color role, in all color groups, to the specified solid color.

See also: [brush()] [set_color()] ColorRole

Sets the color in the specified color group, used for the given color role, to the specified solid color.

See also: [set_brush()] [color()] ColorRole

Sets a the group at cg. You can pass either brushes, pixmaps or plain colors for windowText, button, light, dark, mid, text, bright_text, base and window.

See also: Brush

Sets the brush for the given color role to the specified brush for all groups in the palette.

See also: [brush()] [set_color()] ColorRole

Overloads Sets the brush in the specified color group, used for the given color role, to brush.

See also: [brush()] [set_color()] ColorRole

Returns true if the ColorGroup cg and ColorRole cr has been set previously on this palette; otherwise returns false.

See also: [set_brush()]

Sets the brush for the given color role to the specified brush for all groups in the palette.

See also: [brush()] [set_color()] ColorRole

Overloads Sets the brush in the specified color group, used for the given color role, to brush.

See also: [brush()] [set_color()] ColorRole

Sets a the group at cg. You can pass either brushes, pixmaps or plain colors for windowText, button, light, dark, mid, text, bright_text, base and window.

See also: Brush

Returns true (usually quickly) if color group cg1 is equal to cg2; otherwise returns false.

Overloads Returns the color that has been set for the given color role in the current ColorGroup.

See also: [brush()] ColorRole

Returns the color in the specified color group, used for the given color role.

See also: [brush()] [set_color()] ColorRole

Overloads Returns the brush that has been set for the given color role in the current ColorGroup.

See also: [color()] [set_brush()] ColorRole

Returns the brush in the specified color group, used for the given color role.

See also: [color()] [set_brush()] ColorRole

Use windowText() instead.

Returns the window text (general foreground) brush of the current color group.

See also: ColorRole [brush()]

Returns the button brush of the current color group.

See also: ColorRole [brush()]

Returns the button text foreground brush of the current color group.

See also: ColorRole [brush()]

Returns the light brush of the current color group.

See also: ColorRole [brush()]

Returns the dark brush of the current color group.

See also: ColorRole [brush()]

Returns the midlight brush of the current color group.

See also: ColorRole [brush()]

Returns the mid brush of the current color group.

See also: ColorRole [brush()]

Returns the text foreground brush of the current color group.

See also: ColorRole [brush()]

Returns the base brush of the current color group.

See also: ColorRole [brush()]

Returns the alternate base brush of the current color group.

See also: ColorRole [brush()]

Returns the tool tip base brush of the current color group. This brush is used by QToolTip and QWhatsThis.

Note: Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.

See also: ColorRole [brush()]

Returns the tool tip text brush of the current color group. This brush is used by QToolTip and QWhatsThis.

Note: Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.

See also: ColorRole [brush()]

Use window() instead.

Returns the window text (general foreground) brush of the current color group.

See also: ColorRole [brush()]

Returns the window (general background) brush of the current color group.

See also: ColorRole [brush()]

Returns the midlight brush of the current color group.

See also: ColorRole [brush()]

Returns the bright text foreground brush of the current color group.

See also: ColorRole [brush()]

Returns the button text foreground brush of the current color group.

See also: ColorRole [brush()]

Returns the shadow brush of the current color group.

See also: ColorRole [brush()]

Returns the highlight brush of the current color group.

See also: ColorRole [brush()]

Returns the highlighted text brush of the current color group.

See also: ColorRole [brush()]

Returns the highlighted text brush of the current color group.

See also: ColorRole [brush()]

Returns the unvisited link text brush of the current color group.

See also: ColorRole [brush()]

Returns the visited link text brush of the current color group.

See also: ColorRole [brush()]

Returns the visited link text brush of the current color group.

See also: ColorRole [brush()]

Returns true if this palette and p are copies of each other, i.e. one of them was created as a copy of the other and neither was subsequently modified; otherwise returns false. This is much stricter than equality.

See also: [operator()] [operator()]

Returns a number that identifies the contents of this QPalette object. Distinct QPalette objects can have the same key if they refer to the same contents.

The cacheKey() will change when the palette is altered.

Returns a new QPalette that has attributes copied from other.

Returns a new QPalette that has attributes copied from other.

Returns a new QPalette that has attributes copied from other.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.