Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QPalette Class Reference

#include <qpalette.h>

List of all members.


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 in Qt contain a palette and 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 most styles, Active and Inactive look the same.

Colors and brushes can be set for particular roles in any of a palette's color groups with setColor() and setBrush(). A color group contains a group of colors used by widgets for drawing themselves. We recommend that widgets use color group roles from the palette such as "foreground" and "base" rather than literal colors like "red" or "turquoise". The color roles are enumerated and defined in the ColorRole documentation.

We strongly recommend that you use the default palette of the current style (returned by QApplication::palette()) and modify that as necessary. This is done by Qt's widgets when they are drawn.

To modify a color group you call the functions setColor() and setBrush(), depending on whether you want a pure color or a pixmap pattern.

There are also corresponding color() and brush() getters, and a commonly used convenience function to get the ColorRole for the current ColorGroup: window(), windowText(), base(), etc.

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

QPalette is optimized by the use of {implicit sharing}, so it is very efficient to pass QPalette objects as arguments.

Warning:
Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for both the Windows XP, Windows Vista, and the Mac OS X styles.
See also:
QApplication::setPalette(), QWidget::setPalette(), QColor

Definition at line 63 of file qpalette.h.


Public Types

enum  ColorGroup {
  Active, Disabled, Inactive, NColorGroups,
  Current, All, Normal = Active
}
enum  ColorRole {
  WindowText, Button, Light, Midlight,
  Dark, Mid, Text, BrightText,
  ButtonText, Base, Window, Shadow,
  Highlight, HighlightedText, Link, LinkVisited,
  AlternateBase, NoRole, ToolTipBase, ToolTipText,
  NColorRoles = ToolTipText + 1, Foreground = WindowText, Background = Window
}

Public Member Functions

const QBrushalternateBase () const
const QBrushbackground () const
const QBrushbase () const
const QBrushbrightText () const
const QBrushbrush (ColorRole cr) const
const QBrushbrush (ColorGroup cg, ColorRole cr) const
const QBrushbutton () const
const QBrushbuttonText () const
qint64 cacheKey () const
const QColorcolor (ColorRole cr) const
const QColorcolor (ColorGroup cg, ColorRole cr) const
ColorGroup currentColorGroup () const
const QBrushdark () const
const QBrushforeground () const
const QBrushhighlight () const
const QBrushhighlightedText () const
bool isBrushSet (ColorGroup cg, ColorRole cr) const
bool isCopyOf (const QPalette &p) const
bool isEqual (ColorGroup cr1, ColorGroup cr2) const
const QBrushlight () const
const QBrushlink () const
const QBrushlinkVisited () const
const QBrushmid () const
const QBrushmidlight () const
 operator QVariant () const
bool operator!= (const QPalette &p) const
QPaletteoperator= (const QPalette &palette)
bool operator== (const QPalette &p) const
 QPalette (const QPalette &palette)
 QPalette (const QColor &windowText, const QColor &window, const QColor &light, const QColor &dark, const QColor &mid, const QColor &text, const QColor &base)
 QPalette (const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &window)
 QPalette (const QColor &button, const QColor &window)
 QPalette (Qt::GlobalColor button)
 QPalette (const QColor &button)
 QPalette ()
void resolve (uint mask)
uint resolve () const
QPalette resolve (const QPalette &) const
int serialNumber () const
void setBrush (ColorGroup cg, ColorRole cr, const QBrush &brush)
void setBrush (ColorRole cr, const QBrush &brush)
void setColor (ColorRole cr, const QColor &color)
void setColor (ColorGroup cg, ColorRole cr, const QColor &color)
void setColorGroup (ColorGroup cr, const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &window)
void setCurrentColorGroup (ColorGroup cg)
const QBrushshadow () const
const QBrushtext () const
const QBrushtoolTipBase () const
const QBrushtoolTipText () const
const QBrushwindow () const
const QBrushwindowText () const
 ~QPalette ()

Private Member Functions

void detach ()
void init ()
void setColorGroup (ColorGroup cr, const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &alternate_base, const QBrush &window, const QBrush &midlight, const QBrush &button_text, const QBrush &shadow, const QBrush &highlight, const QBrush &highlighted_text, const QBrush &link, const QBrush &link_visited, const QBrush &toolTipBase, const QBrush &toolTipText)
void setColorGroup (ColorGroup cr, const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &alternate_base, const QBrush &window, const QBrush &midlight, const QBrush &button_text, const QBrush &shadow, const QBrush &highlight, const QBrush &highlighted_text, const QBrush &link, const QBrush &link_visited)

Private Attributes

uint current_group: 4
QPalettePrivate * d
uint resolve_mask: 28

Friends

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &s, const QPalette &p)

Related Functions

(Note that these are not member functions.)

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

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index