# QColorGroup Class Reference

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

`#include <qpalette.h>`

List of all member functions.

## Public Members

- QColorGroup ()
- QColorGroup ( const QColor & foreground, const QColor & background, const QColor & light, const QColor & dark, const QColor & mid, const QColor & text, const QColor & base )
- ~QColorGroup ()
- const QColor& foreground () const
- const QColor& background () const
- const QColor& light () const
- QColor midlight () const
- const QColor& dark () const
- const QColor& mid () const
- const QColor& text () const
- const QColor& base () const
- bool operator== ( const QColorGroup & g ) const
- bool operator!= ( const QColorGroup & g ) const

## Related Functions

(Note that these are not member functions.)

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

## 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 eight distinct color roles:

1. Foreground (graphics foreground color)
2. Background (general background color)
3. Light (lighter than background color, for shadow effects)
4. Midlight (between Background and Light, for shadow effects)
5. Dark (darker than the background color, for shadow effects)
6. Medium (between background 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. Base (used as background color for some widgets). Usually white or another light color.

We have not seen any good, well-made and usable widgets that use more than these eight color roles.

A QPalette contains three color groups.

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

See also: QColor and QPalette.

Examples: xform/xform.cpp

## Member Function Documentation

### QColorGroup::QColorGroup ()

Constructs a color group with all colors set to black.

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

Constructs a color group with the specified colors.

### 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::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::light () const

Returns the light color of the color group.

### const QColor & QColorGroup::mid () const

Returns the medium color of the color group.

### QColor QColorGroup::midlight () const

Returns the midlight color of the color group. Currently, this is a lightened version of the background, 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==().

### const QColor & QColorGroup::text () const

Returns the text foreground color of the color group.

## Related Functions

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

Writes a color group to the stream.

Serialization format:

1. QColor foreground
2. QColor background
3. QColor light
4. QColor dark
5. QColor mid
6. QColor text
7. QColor base

The colors are serialized in the listed order.

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

Reads a color group from 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-99 Troll Tech, all rights reserved.

It was generated from the following files:

- qpalette.h: 1998/08/25
- qpalette.cpp: 1998/07/03