The QPalette class contains color groups for each widget state. More...
#include <qpalette.h>
A palette consists of three color groups: a active, a disabled and an inactive color group. All widgets contain a palette, and all the widgets in Qt use their palette to draw themselves. This makes the user interface consistent and easily configurable.
If you make a new widget you are strongly advised to use the colors in the palette rather than hard-coding specific colors.
The color groups are:
Of course, both active and inactive windows can contain disabled widgets. (Disabled widgets are often called inaccessible or grayed out.)
In Motif style, active() and inactive() look precisely the same. In Windows 2000 style and Macintosh Platinum style, the two styles look slightly different.
There are setActive(), setInactive() and setDisabled() functions to modify the palette. Qt also supports a normal() group; this is an obsolete alias for active(), supported for backward compatibility.
(The split between normal() and active() prior to Qt 2.1 did not work except in the simplest of cases, hence the change to the current, more powerful design.)
See also QApplication::setPalette(), QWidget::setPalette(), QColorGroup and QColor.
Examples: i18n/main.cpp
Constructs a palette that consists of color groups with only black colors.
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Constructs a palette from the button color. The other colors are automatically calculated, based on this color. Background will be the button color as well.
Constructs a palette from a button color and a background. The other colors are automatically calculated, based on these colors.
Constructs a palette that consists of the three color groups active, disabled and inactive. See QPalette for definitions of the color groups and QColorGroup::ColorRole for definitions of each color role in the three groups.
See also QColorGroup, QColorGroup::ColorRole and QPalette.
Constructs a copy of p.
This constructor is fast (it uses copy-on-write).
Destructs the palette.
Returns the active color group of this palette.
See also QColorGroup, setActive(), inactive() and disabled().
Returns the brush in gr used for color role r.
See also color(), setBrush() and QColorGroup::ColorRole.
Returns the color in gr used for color role r.
See also brush(), setColor() and QColorGroup::ColorRole.
Return a deep copy of this palette. This is slower than the copy constructor and assignment operator and offers no advantages any more.
Returns the disabled color group of this palette.
See also QColorGroup, setDisabled(), active() and inactive().
Returns the inactive color group of this palette.
See also QColorGroup, setInactive(), active() and disabled().
Returns TRUE if this palette and p are copies of each other, ie. one of them was created as a copy of the other and neither was subsequently modified. This is much stricter than equality.
See also operator= and operator==.
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use active() instead.
Returns TRUE (slowly) if this palette is different from p, or FALSE (usually quickly) if they are equal.
Assigns p to this palette and returns a reference to this palette.
This is fast (it uses copy-on-write).
See also copy().
Returns TRUE (usually quickly) if this palette is equal to p, or FALSE (slowly) if they are different.
Returns a number that uniquely identifies this QPalette object. The serial number is intended for caching. Its value may not be used for anything other than equality testing.
Note that QPalette uses copy-on-write, and the serial number changes during the lazy copy operation (detach()), not during a shallow copy (copy constructor or assignment).
See also QPixmap, QPixmapCache and QCache.
Sets the Active
color group to g.
See also active(), setDisabled(), setInactive() and QColorGroup.
Sets the brush in for color role r in all three color groups to b.
See also brush(), setColor(), QColorGroup::ColorRole, active(), inactive() and disabled().
Sets the brush in gr used for color role r to b.
See also brush(), setColor() and QColorGroup::ColorRole.
Sets the color of the brush in gr used for color role r to c.
See also color(), setBrush() and QColorGroup::ColorRole.
Sets the brush in gr used for color role r to the solid color c.
See also setBrush(), color() and QColorGroup::ColorRole.
Sets the Disabled
color group to g.
See also disabled(), setActive() and setInactive().
Sets the Inactive
color group to g.
See also active(), setDisabled(), setActive() and QColorGroup.
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use setActive() instead.
Reads a palette from the stream and returns a reference to the stream.
See also Format of the QDataStream operators
Writes a palette to the stream and returns a reference to the stream.
See also Format of the QDataStream operators
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright © 2000 Trolltech | Trademarks | Qt version 2.2.1
|