Qt logo

QPalette Class Reference


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

#include <qpalette.h>

List of all member functions.

Public Members

Related Functions

(Note that these are not member functions.)

Detailed Description

The QPalette class contains color groups for each widget state.

A palette consists of three color groups: a normal, a disabled and an active 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 active group is used for the widget in focus. Normally it contains the same colors as normal so as not to overwhelm the user with bright and flashing colors, but if you need to you can change it.

The disabled group is used for widgets that are currently inactive or not usable.

The normal color group is used in all other cases.

See also: QApplication::setPalette(), QWidget::setPalette(), QColorGroup and QColor.

Examples: xform/xform.cpp widgets/widgets.cpp


Member Function Documentation

QPalette::QPalette ()

Constructs a palette that consists of color groups with only black colors.

QPalette::QPalette ( const QColor & background )

Constructs a palette from the background color. The other colors are automatically calculated, based on this color.

QPalette::QPalette ( const QColorGroup & normal, const QColorGroup & disabled, const QColorGroup & active )

Constructs a palette that consists of the three color groups normal, disabled and active.

QPalette::QPalette ( const QPalette & p )

Constructs a palette that is a shallow copy of p.

See also: copy().

QPalette::~QPalette ()

Destroys the palette.

const QColorGroup & QPalette::active () const

Returns the active color group of this palette.

See also: QColorGroup, normal(), disabled() and setActive().

QPalette QPalette::copy () const

Returns a deep copy of the palette.

const QColorGroup & QPalette::disabled () const

Returns the disabled color group of this palette.

See also: QColorGroup, normal(), active() and setDisabled().

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

Returns the normal color group of this palette.

See also: QColorGroup, disabled(), active() and setNormal().

bool QPalette::operator!= ( const QPalette & p ) const

Returns TRUE if this palette is different from p, or FALSE if they are equal.

QPalette & QPalette::operator= ( const QPalette & p )

Assigns p to this palette and returns a reference to this palette. Note that a shallow copy of p is used.

See also: copy().

bool QPalette::operator== ( const QPalette & p ) const

Returns TRUE if this palette is equal to p, or FALSE if they are different.

int QPalette::serialNumber () const

Returns a number that uniquely identifies this QPalette object. The serial number is very useful for caching.

See also: QPixmap and QPixmapCache.

void QPalette::setActive ( const QColorGroup & g )

Sets the active color group to g.

See also: active().

void QPalette::setDisabled ( const QColorGroup & g )

Sets the disabled color group to g.

See also: disabled().

void QPalette::setNormal ( const QColorGroup & g )

Sets the normal color group to g.

See also: normal().


Related Functions

QDataStream & operator<< (QDataStream & s, const QPalette & p)

Writes a palette to the stream and returns a reference to the stream.

Serialization format:

  1. QColorGroup normal
  2. QColorGroup disabled
  3. QColorGroup active
The color groups are serialized in the listed order.

QDataStream & operator>> (QDataStream & s, QPalette & p)

Reads a palette from the stream and returns a reference to the stream.


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-98 Troll Tech, all rights reserved.

It was generated from the following files:


Copyright © 1998 Troll TechTrademarks
Qt version 1.42