QPalette Class Reference
The QPalette class contains color groups for each widget state.
More...
#include <qpalette.h>
List of all member functions.
Public Members
QPalette ( const QColor & button ) (obsolete)
QPalette ( const QColor & button, const QColor & background )
QPalette ( const QColorGroup & active, const QColorGroup & disabled, const QColorGroup & inactive )
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 )
const QColorGroup &
active () const
const QColorGroup & normal () const
void setNormal ( const QColorGroup & cg )
const QColor & backgroundColorForMode ( ColorGroup, Qt::BackgroundMode )
void setBackgroundColorForMode ( ColorGroup, Qt::BackgroundMode, const QColor & )
const QColor & foregroundColorForMode ( ColorGroup, Qt::BackgroundMode )
void setForegroundColorForMode ( ColorGroup, Qt::BackgroundMode, const QColor & )
const QPixmap * backgroundPixmapForMode ( ColorGroup, Qt::BackgroundMode )
void setBackgroundPixmapForMode ( ColorGroup, Qt::BackgroundMode, const QPixmap & )
Related Functions
QDataStream &
operator<< ( QDataStream & s, const QPalette & p )
QDataStream &
operator>> ( QDataStream & s, QPalette & p )
Detailed 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 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.
See also QApplication::setPalette(), QWidget::palette, QColorGroup and QColor.
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 QPalette 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: themes/metal.cpp and themes/wood.cpp.
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.
QPalette QPalette::copy () const
Returns a deep copy of this palette. This is slower than the copy
constructor and assignment operator and no longer offers any advantages.
const QColorGroup & QPalette::disabled () const
Returns the disabled color group of this palette.
See also QColorGroup, setDisabled(), active() and inactive().
Examples: themes/metal.cpp and themes/wood.cpp.
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==.
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 ( 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.
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 gr used for color role r to the solid color c.
See also setBrush(), color() and QColorGroup::ColorRole.
Example: themes/themes.cpp.
Sets the brush color used for color role r to 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.
Related Functions
Writes a palette to the stream and returns a reference to the stream.
See also Format of the QDataStream operators.
Reads a palette from 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-2001
Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks
| Qt version 3.0.0-beta1-beta1
|