QPalette(3qt)

NAME
QPalette - Color groups for each widget state

#include <qpalette.h>

  Public Members
QPalette ()
QPalette ( const QColor & button ) (obsolete)
QPalette ( const QColor & button, const QColor & background )
QPalette ( const QColorGroup & active, const QColorGroup & disabled, const QColorGroup & inactive )
QPalette ( const QPalette & )
~QPalette ()
QPalette& operator= ( const QPalette & )
enum ColorGroup { Normal, Disabled, Active, Inactive, NColorGroups }
const QColor& color ( ColorGroup, QColorGroup::ColorRole ) const
const QBrush& brush ( ColorGroup, QColorGroup::ColorRole ) const
void setColor ( ColorGroup, QColorGroup::ColorRole, const QColor & )
void setBrush ( ColorGroup, QColorGroup::ColorRole, const QBrush & )
void setColor ( QColorGroup::ColorRole, const QColor & )
void setBrush ( QColorGroup::ColorRole, const QBrush & )
QPalette copy () const
const QColorGroup& active () const
const QColorGroup& disabled () const
const QColorGroup& inactive () const
const QColorGroup& normal () const (obsolete)
void setActive ( const QColorGroup & )
void setDisabled ( const QColorGroup & )
void setInactive ( const QColorGroup & )
void setNormal ( const QColorGroup & ) (obsolete)
bool operator== ( const QPalette & p ) const
bool operator!= ( const QPalette & p ) const
bool isCopyOf ( const QPalette & )
int serialNumber () const

RELATED FUNCTION DOCUMENTATION
(Note that these are not member functions.)
QDataStream & operator>> (QDataStream & s, QPalette & p)
QDataStream & operator<< (QDataStream & s, const QPalette & p)

DESCRIPTION
The QPalette class contains color groups for each widget state.

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:

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.

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

MEMBER FUNCTION DOCUMENTATION

QPalette::QPalette ()
Constructs a palette that consists of color groups with only black colors.

QPalette::QPalette ( const QColor & button )
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.

QPalette::QPalette ( const QColor & button, const QColor & background )
Constructs a palette from a button color and a background. The other colors are automatically calculated, based on these colors.

QPalette::QPalette ( const QColorGroup & active, const QColorGroup & disabled, const QColorGroup & inactive )
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.

QPalette::QPalette ( const QPalette & p )
Constructs a copy of p.

This constructor is fast (it uses copy-on-write).

QPalette::~QPalette ()
Destructs the palette.

const QColorGroup & QPalette::active () const
Returns the active color group of this palette.

See also QColorGroup, setActive(), inactive() and disabled().

const QBrush & QPalette::brush ( ColorGroup gr, QColorGroup::ColorRole r ) const
Returns the brush in gr used for color role r.

See also color(), setBrush() and QColorGroup::ColorRole.

const QColor & QPalette::color ( ColorGroup gr, QColorGroup::ColorRole r ) const
Returns the color in gr used for color role r.

See also brush(), setColor() and QColorGroup::ColorRole.

QPalette QPalette::copy () const
Return a deep copy of this palette. This is slower than the copy constructor and assignment operator and offers no advantages any more.

const QColorGroup & QPalette::disabled () const
Returns the disabled color group of this palette.

See also QColorGroup, setDisabled(), active() and inactive().

const QColorGroup & QPalette::inactive () const
Returns the inactive color group of this palette.

See also QColorGroup, setInactive(), active() and disabled().

bool QPalette::isCopyOf ( const QPalette & p )
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==.

const QColorGroup & QPalette::normal () const
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.

bool QPalette::operator!= ( const QPalette & p ) const
Returns TRUE (slowly) if this palette is different from p, or FALSE (usually quickly) if they are equal.

QPalette & QPalette::operator= ( const QPalette & p )
Assigns p to this palette and returns a reference to this palette.

This is fast (it uses copy-on-write).

See also copy().

bool QPalette::operator== ( const QPalette & p ) const
Returns TRUE (usually quickly) if this palette is equal to p, or FALSE (slowly) if they are different.

int QPalette::serialNumber () const
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.

void QPalette::setActive ( const QColorGroup & g )
Sets the Active color group to g.

See also active(), setDisabled(), setInactive() and QColorGroup.

void QPalette::setBrush ( QColorGroup::ColorRole r, const QBrush & b )
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().

void QPalette::setBrush ( ColorGroup gr, QColorGroup::ColorRole r, const QBrush & b )
Sets the brush in gr used for color role r to b.

See also brush(), setColor() and QColorGroup::ColorRole.

void QPalette::setColor ( QColorGroup::ColorRole r, const QColor & c )
Sets the color of the brush in gr used for color role r to c.

See also color(), setBrush() and QColorGroup::ColorRole.

void QPalette::setColor ( ColorGroup gr, QColorGroup::ColorRole r, const QColor & c )
Sets the brush in gr used for color role r to the solid color c.

See also setBrush(), color() and QColorGroup::ColorRole.

void QPalette::setDisabled ( const QColorGroup & g )
Sets the Disabled color group to g.

See also disabled(), setActive() and setInactive().

void QPalette::setInactive ( const QColorGroup & g )
Sets the Inactive color group to g.

See also active(), setDisabled(), setActive() and QColorGroup.

void QPalette::setNormal ( const QColorGroup & g )
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.

RELATED FUNCTION DOCUMENTATION

QDataStream & operator>> (QDataStream & s, QPalette & p)
Reads a palette from the stream and returns a reference to the stream.

See also Format of the QDataStream operators

QDataStream & operator<< (QDataStream & s, const QPalette & p)
Writes a palette to the stream and returns a reference to the stream.

See also Format of the QDataStream operators

SEE ALSO
http://doc.trolltech.com/qpalette.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports make our job much simpler. Thank you.

In case of content or formattting problems with this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qpalette.3qt) and the Qt version (2.3.1).