The QColorGroup class contains a group of widget colors. More...
#include <qpalette.h>
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. The color roles are enumerated and defined in the ColorRole documentation.
The most common usage of QColorGroup is like this:
QPainter p; ... p.setPen( colorGroup().foreground() ); p.drawLine( ... )
See the ColorRole documentation below for more details on roles.
It's also possible to modify color groups or create them from scratch.
The color group class can be created using three different constructors, or by modifying one supplied by the system. The default constructor creates an all-black color group, which can then be modified using set functions. There are two functions that take long lists of arguments (slightly different lists - beware!). And there is the copy constructor.
We strongly recommend using a system-supplied color group, and modifying that as necessary.
You modify a color group by calling the access functions setColor() and setBrush(), depending on whether you want a pure color or e.g. a pixmap pattern.
There are also corresponding color() and brush() getters, and a commonly used convenience function to get each ColorRole: background(), foreground(), base() and so on.
See also QColor, QPalette and QWidget::colorGroup().
Background
- general background color.
Foreground
- general foreground color.
Base
- used as background color for e.g. text entry widgets,
usually white or another light color.
Text
- the foreground color used with Base.
Usually this
is the same as the Foreground,
in what case it must provide good
contrast both with Background
and Base.
Button
- general button background color, where buttons need a
background different from Background,
as in the Macintosh style.
ButtonText
- a foreground color used with the Button
color.
Light
- lighter than Button
color.
Midlight
- between Button
and Light.
Dark
- darker than Button.
Mid
- between Button
and Dark.
Shadow
- a very dark color.
Background,
and used
in ways that depend on that relationship. For example, buttons
depend on it to make the bevels look good, and Motif scroll bars
depend on Mid
to be slightly different from Background.
Selected (marked) items have two roles:
Highlight
- a color to indicate a selected or highlighted item.
HighlightedText
- a text color that contrasts to Highlight.
Text
or Foreground
would provide bad contrast,
such as on pressed push buttons: BrightText
- a text color that is very different from Foreground
and contrasts well with e.g. Dark.
Note that text colors can be used for other things than just words: text colors are usually used for text, but it's quite common to have lines, icons and so on that belong with a text color logically.
This image shows most of the color roles in use:
Constructs a color group with all colors set to black.
Constructs a color group. You can pass either brushes, pixmaps or plain colors for each parameter.
This constructor can be very handy sometimes, but don't overuse it: Such long lists of arguments are rather error-prone.
See also QBrush.
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Constructs a color group with the specified colors. The button color will be set to the background color.
Constructs a color group that is an independent copy of other.
Destructs the color group.
Returns the background color of the color group.
See also ColorRole.
Returns the base color of the color group.
See also ColorRole.
Returns the bright text foreground color of the color group.
See also ColorRole.
Returns the brush that has been set for color role r.
See also color(), setBrush() and ColorRole.
Returns the button color of the color group.
See also ColorRole.
Returns the button text foreground color of the color group.
See also ColorRole.
Returns the color that has been set for color role r.
See also brush() and ColorRole.
Returns the dark color of the color group.
See also ColorRole.
Returns the foreground color of the color group.
See also ColorRole.
Returns the highlight color of the color group.
See also ColorRole.
Returns the highlighted text color of the color group.
See also ColorRole.
Returns the light color of the color group.
See also ColorRole.
Returns the medium color of the color group.
See also ColorRole.
Returns the midlight color of the color group.
See also ColorRole.
Returns TRUE if this color group is different from g, or FALSE if it is equal to g.
See also operator!=().
Returns TRUE if this color group is equal to g, or FALSE if it is different from g.
See also operator==().
Sets the brush used for color role r to b.
See also brush(), setColor() and ColorRole.
Sets the brush used for color role r to a solid color c.
See also brush(), setColor() and ColorRole.
Returns the shadow color of the color group.
See also ColorRole.
Returns the text foreground color of the color group.
See also ColorRole.
Reads a color group from the stream.
See also Format of the QDataStream operators
Writes a color group 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-2000 Trolltech, all rights reserved.
Copyright İ 2000 Trolltech | Trademarks | Qt version 2.2.1
|