Qt logo

QColorGroup Class Reference


The QColorGroup class contains a group of widget colors. More...

#include <qpalette.h>

List of all member functions.

Public Members

Related Functions

(Note that these are not member functions.)

Detailed Description

The QColorGroup class contains a group of widget colors.

A color group contains a group of colors used by widgets for drawing themselves. Widgets should not use colors like "red" and "turqoise" but rather "foreground" and "base", where possible.

We have identified fourty-two distinct color roles:

  1. Foreground (graphics foreground color)
  2. Button (general button color)
  3. Light (lighter than button color, for shadow effects)
  4. Midlight (between Button and Light, for shadow effects)
  5. Dark (darker than the button color, for shadow effects)
  6. Medium (between button color and dark, used for shadow and contrast effects)
  7. Text (usually the same as the foreground color, but sometimes text and other foreground are not the same)
  8. BrightText (a text color that contrasts to the Dark color)
  9. ButtonText (a text color that contrasts to the Button color)
  10. Base (used as background color for some widgets). Usually white or another light color.
  11. Background (general background color)
  12. Shadow (a very dark color used for shadow effects, usually black)
  13. Highlight (a color to indicate a selected or highlighted item)
  14. HighlightedText (a text color that contrasts to Highlight)

A QPalette contains three color groups.

The current widget color group is returned by QWidget::colorGroup().

See also: QColor and QPalette.


Member Function Documentation

QColorGroup::QColorGroup ()

Constructs a color group with all colors set to black.

QColorGroup::QColorGroup ( const QBrush & foreground, const QBrush & button, const QBrush & light, const QBrush & dark, const QBrush & mid, const QBrush & text, const QBrush & bright_text, const QBrush & base, const QBrush & background )

Constructs a color group. You can pass either brushes, pixmaps or plain colors for each parameter.

See also: QBrush.

QColorGroup::QColorGroup ( const QColor & foreground, const QColor & button, const QColor & light, const QColor & dark, const QColor & mid, const QColor & text, const QColor & base )

This function is obsolete. It is provided to keep old programs working. We strongly advise against using it in new code.

Constructs a color group with the specified colors. The background color will be set to the button color.

QColorGroup::QColorGroup ( const QColorGroup & other )

Constructs a color group that is an independent copy of another color group.

QColorGroup::~QColorGroup ()

Destroys the color group.

const QColor & QColorGroup::background () const

Returns the background color of the color group.

const QColor & QColorGroup::base () const

Returns the base color of the color group.

const QColor & QColorGroup::brightText () const

Returns the bright text foreground color of the color group.

const QBrush & QColorGroup::brush ( ColorRole r ) const

Returns the brush that has been set for color role r.

const QColor & QColorGroup::button () const

Returns the button color of the color group.

const QColor & QColorGroup::buttonText () const

Returns the button text foreground color of the color group.

const QColor & QColorGroup::color ( ColorRole r ) const

Returns the color that has been set for color role r.

See also: brush().

const QColor & QColorGroup::dark () const

Returns the dark color of the color group.

const QColor & QColorGroup::foreground () const

Returns the foreground color of the color group.

const QColor & QColorGroup::highlight () const

Returns the highlight color of the color group.

const QColor & QColorGroup::highlightedText () const

Returns the highlighted text color of the color group.

const QColor & QColorGroup::light () const

Returns the light color of the color group.

const QColor & QColorGroup::mid () const

Returns the medium color of the color group.

const QColorQColorGroup::midlight () const

Returns the midlight color of the color group. Currently, this is a lightened version of the button color, but this may change in the future, to return a const QColor & from the palette.

bool QColorGroup::operator!= ( const QColorGroup & g ) const

Returns TRUE if this color group is different from g, or FALSE if it is equal to g.

See also: operator!=().

bool QColorGroup::operator== ( const QColorGroup & g ) const

Returns TRUE if this color group is equal to g, or FALSE if it is different from g.

See also: operator==().

void QColorGroup::setBrush ( ColorRole r, const QBrush & b )

Sets the brush used for color role r to b.

void QColorGroup::setColor ( ColorRole r, const QColor & c )

Sets the brush used for color role r to a solid color c.

const QColor & QColorGroup::shadow () const

Returns the shadow color of the color group.

const QColor & QColorGroup::text () const

Returns the text foreground color of the color group.


Related Functions

QDataStream & operator>> (QDataStream & s, QColorGroup & g)

Reads a color group from the stream.

QDataStream & operator<< (QDataStream & s, const QColorGroup & g)

Writes a color group to the stream.

Serialization format:

  1. QBrush foreground
  2. QBrush button
  3. QBrush light
  4. QBrush midLight
  5. QBrush dark
  6. QBrush mid
  7. QBrush text
  8. QBrush brightText
  9. QBrush ButtonText
  10. QBrush base
  11. QBrush background
  12. QBrush shadow
  13. QBrush highlight
  14. QBrush highlightedText
The colors are serialized in the listed order.

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


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


Copyright İ 1999 Troll TechTrademarks
Qt version 2.0.2