QPalette(3qt)

NAME
QPalette - Color groups for each widget state

SYNOPSIS
#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 & p )
~QPalette ()
QPalette & operator= ( const QPalette & p )
enum ColorGroup { Disabled, Active, Inactive, NColorGroups, Normal = Active }
const QColor & color ( ColorGroup gr, QColorGroup::ColorRole r ) const
const QBrush & brush ( ColorGroup gr, QColorGroup::ColorRole r ) const
void setColor ( ColorGroup gr, QColorGroup::ColorRole r, const QColor & c )
void setBrush ( ColorGroup gr, QColorGroup::ColorRole r, const QBrush & b )
void setColor ( QColorGroup::ColorRole r, const QColor & c )
void setBrush ( QColorGroup::ColorRole r, const QBrush & b )
QPalette copy () const
const QColorGroup & active () const
const QColorGroup & disabled () const
const QColorGroup & inactive () const
const QColorGroup & normal () const (obsolete)
void setActive ( const QColorGroup & g )
void setDisabled ( const QColorGroup & g )
void setInactive ( const QColorGroup & g )
void setNormal ( const QColorGroup & cg ) (obsolete)
bool operator== ( const QPalette & p ) const
bool operator!= ( const QPalette & p ) const
bool isCopyOf ( const QPalette & p )
int serialNumber () const

RELATED FUNCTION DOCUMENTATION
QDataStream & operator<< ( QDataStream & s, const QPalette & p )
QDataStream & operator>> ( QDataStream & s, QPalette & p )

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

A palette consists of three color groups: active, disabled, and inactive. All widgets contain a palette, and all widgets in Qt 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 Motif style, active() and inactive() look 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 backwards compatibility.)

Colors and brushes can be set for particular roles in any of a palette's color groups with setColor() and setBrush().

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

See also QApplication::setPalette(), QWidget::palette, QColorGroup, QColor, Widget Appearance and Style, Graphics Classes, Image Processing Classes, and Implicitly and Explicitly Shared Classes.

  Member Type Documentation

QPalette::ColorGroup

QPalette::Disabled

QPalette::Active

QPalette::Inactive

QPalette::NColorGroups

QPalette::Normal - synonym for Active

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. 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 the Detailed Description for definitions of the color groups and QColorGroup::ColorRole for definitions of each color role in the three groups.

See also QColorGroup and QColorGroup::ColorRole.

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

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

QPalette::~QPalette ()
Destroys the palette.

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

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

Examples:

const QBrush & QPalette::brush ( ColorGroup gr, QColorGroup::ColorRole r ) const
Returns the brush in color group 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 color group gr, used for color role r.

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

QPalette QPalette::copy () const
Returns a deep copy of this palette.

Warning: This is slower than the copy constructor and assignment operator and offers no benefits.

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

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

Examples:

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, 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=() and operator==().

const QColorGroup & QPalette::normal () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Returns the active color group. Use active() instead.

See also setActive() and active().

bool QPalette::operator!= ( const QPalette & p ) const
Returns TRUE (slowly) if this palette is different from p; otherwise returns FALSE (usually quickly).

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; otherwise returns FALSE (slowly).

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 ( ColorGroup gr, QColorGroup::ColorRole r, const QBrush & b )
Sets the brush in color group gr, used for color role r, to b.

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

void QPalette::setBrush ( QColorGroup::ColorRole r, const QBrush & b )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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::setColor ( ColorGroup gr, QColorGroup::ColorRole r, const QColor & c )
Sets the brush in color group gr, used for color role r, to the solid color c.

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

Example: themes/themes.cpp.

void QPalette::setColor ( QColorGroup::ColorRole r, const QColor & c )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the brush color used for color role r to color c in all three color groups.

See also color(), setBrush(), 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 & cg )
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Sets the active color group to cg. Use setActive() instead.

See also setActive() and active().

RELATED FUNCTION DOCUMENTATION

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

See also Format of the QDataStream operators.

QDataStream & operator>> ( QDataStream & s, QPalette & p )
Reads a palette from the stream, s into the palette p, 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 help us to help you. Thank you.

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in 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 (3.3.5).