QColorGroup(3qt)
π QColorGroup π β the QColorGroup(3qt) manual, bestie edition
okay so you opened the QColorGroup(3qt) page and you're like "what is this" β don't worry, I got you. This is the whole thing, every single flag, role and default, just with the vibes turned all the way up. Let's go π«Ά
π NAME π
QColorGroup β a whole group of widget colors. That's it. That's the name. A squad of colors, if you will. π
β¨ SYNOPSIS β¨
#include <qpalette.h>
π 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 ) (obsolete)
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 )
QColorGroup ( const QColorGroup & other )
~QColorGroup ()
QColorGroup & operator= ( const QColorGroup & other )
enum ColorRole { Foreground, Button, Light, Midlight, Dark, Mid, Text,
BrightText, ButtonText, Base, Background, Shadow, Highlight,
HighlightedText, Link, LinkVisited, NColorRoles }
const QColor & color ( ColorRole r ) const
const QBrush & brush ( ColorRole r ) const
void setColor ( ColorRole r, const QColor & c )
void setBrush ( ColorRole r, const QBrush & b )
const QColor & foreground () const
const QColor & button () const
const QColor & light () const
const QColor & dark () const
const QColor & mid () const
const QColor & text () const
const QColor & base () const
const QColor & background () const
const QColor & midlight () const
const QColor & brightText () const
const QColor & buttonText () const
const QColor & shadow () const
const QColor & highlight () const
const QColor & highlightedText () const
const QColor & link () const
const QColor & linkVisited () const
bool operator== ( const QColorGroup & g ) const
bool operator!= ( const QColorGroup & g ) const
so like, quick rundown of what's in the box:
QColorGroup ()β the default one, everything's black.QColorGroup ( ... )with sevenQColors β the obsolete one, no cap, the docs literally say don't use it in new code.QColorGroup ( ... )with nineQBrushes β the real one, brushes/pixmaps/plain colors all welcome.QColorGroup ( const QColorGroup & other )β copy constructor, makes an independent twin.~QColorGroup ()β destructor, bye.operator=β copies another group's colors onto you.enum ColorRoleβ the icon list of roles:Foreground,Button,Light,Midlight,Dark,Mid,Text,BrightText,ButtonText,Base,Background,Shadow,Highlight,HighlightedText,Link,LinkVisited,NColorRoles.color()/brush()β getters by role.setColor()/setBrush()β setters by role.- a whole bouquet of convenience getters:
foreground(),button(),light(),dark(),mid(),text(),base(),background(),midlight(),brightText(),buttonText(),shadow(),highlight(),highlightedText(),link(),linkVisited(). operator==/operator!=β are you the same or not, fr fr.
πΈ RELATED FUNCTION DOCUMENTATION πΈ
QDataStream & operator<< ( QDataStream & s, const QColorGroup & g )
(it gets its own section here AND at the bottom, because the docs said so and we respect the docs β¨)
π¦ DESCRIPTION π¦
The QColorGroup class contains a group of widget colors.
okay so real talk: a color group is literally a lil bundle of colors that widgets use to draw themselves. And the docs are begging you β please, bestie β use the symbolic roles like "foreground" and "base" instead of hardcoding literal colors like "red" or "turquoise". The roles are all enumerated and defined down in the ColorRole docs, and you should go read those, they're iconic.
The most common way you'll ever use QColorGroup looks like this:
QPainter p;
...
p.setPen( colorGroup().foreground() );
p.drawLine( ... )
You can also modify color groups, or build brand new ones from scratch. Main character energy either way π
There are three different constructors for making one, or you can just take one that Qt hands you and tweak it:
- the default constructor makes an all-black color group, which you then poke at with the set functions,
- there's a constructor where you specify all the colors,
- and there's a copy constructor.
We strongly recommend using a system-supplied color group and modifying that as necessary. Like, seriously. That's the move.
You modify a color group by calling the access functions setColor() and setBrush() β pick setColor() if you want a pure color, pick setBrush() if you want a pixmap pattern. π¨
There are matching getters, color() and brush(), plus a super commonly used convenience function for every single ColorRole: background(), foreground(), base(), etc. It's giving "we thought of everything".
See also QColor, QPalette, QWidget::colorGroup, Widget Appearance and Style, Graphics Classes, and Image Processing Classes.
π Member Type Documentation π
π QColorGroup::ColorRole π
The ColorRole enum defines the different symbolic color roles used in current GUIs. It's basically the cast list of the whole show. Let's meet everyone:
The central roles are:
QColorGroup::Backgroundβ general background color.QColorGroup::Foregroundβ general foreground color.QColorGroup::Baseβ used as background color for text entry widgets, for example; usually white or another light color.QColorGroup::Textβ the foreground color used withBase. Usually this is the same as theForeground, in which case it must provide good contrast withBackgroundandBase.QColorGroup::Buttonβ general button background color in which buttons need a background different fromBackground, as in the Macintosh style.QColorGroup::ButtonTextβ a foreground color used with theButtoncolor.
There are some color roles used mostly for 3D bevel and shadow effects:
QColorGroup::Lightβ lighter thanButtoncolor.QColorGroup::Midlightβ betweenButtonandLight.QColorGroup::Darkβ darker thanButton.QColorGroup::Midβ betweenButtonandDark.QColorGroup::Shadowβ a very dark color. By default, the shadow color isQt::black.
All of these are normally derived from Background and used in ways that depend on that relationship. For example, buttons depend on it to make the bevels look attractive, and Motif scroll bars depend on Mid to be slightly different from Background. (it's giving "everything is connected" β¨)
Selected (marked) items have two roles:
QColorGroup::Highlightβ a color to indicate a selected item or the current item. By default, the highlight color isQt::darkBlue.QColorGroup::HighlightedTextβ a text color that contrasts withHighlight. By default, the highlighted text color isQt::white.
Finally, there is a special role for text that needs to be drawn where Text or Foreground would give poor contrast, such as on pressed push buttons:
QColorGroup::BrightTextβ a text color that is very different fromForegroundand contrasts well with e.g.Dark.QColorGroup::Linkβ a text color used for unvisited hyperlinks. By default, the link color isQt::blue.QColorGroup::LinkVisitedβ a text color used for already visited hyperlinks. By default, the linkvisited color isQt::magenta.QColorGroup::NColorRolesβ Internal.
Note that text colors can be used for things other than just words; text colors are usually used for text, but it's quite common to use the text color roles for lines, icons, etc. π
This image shows most of the color roles in use:
[Image Omitted]
π 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 )
This function is obsolete. It is provided to keep old source working. 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.
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 foreground, button, light, dark, mid, text, bright_text, base and background.
See also QBrush.
QColorGroup::QColorGroup ( const QColorGroup & other )
Constructs a color group that is an independent copy of other. No shared custody, she's fully her own girl π
QColorGroup::~QColorGroup ()
Destroys the color group. Rest in peace, bestie ποΈ
const QColor & QColorGroup::background () const
Returns the background color of the color group.
See also ColorRole.
const QColor & QColorGroup::base () const
Returns the base color of the color group.
See also ColorRole.
const QColor & QColorGroup::brightText () const
Returns the bright text foreground color of the color group.
See also ColorRole.
Examples:
const QBrush & QColorGroup::brush ( ColorRole r ) const
Returns the brush that has been set for color role r.
See also color(), setBrush(), and ColorRole.
Examples:
const QColor & QColorGroup::button () const
Returns the button color of the color group.
See also ColorRole.
Examples:
const QColor & QColorGroup::buttonText () const
Returns the button text foreground color of the color group.
See also ColorRole.
Examples:
const QColor & QColorGroup::color ( ColorRole r ) const
Returns the color that has been set for color role r.
See also brush() and ColorRole.
const QColor & QColorGroup::dark () const
Returns the dark color of the color group.
See also ColorRole.
Example: themes/wood.cpp.
const QColor & QColorGroup::foreground () const
Returns the foreground color of the color group.
See also ColorRole.
Examples:
const QColor & QColorGroup::highlight () const
Returns the highlight color of the color group.
See also ColorRole.
const QColor & QColorGroup::highlightedText () const
Returns the highlighted text color of the color group.
See also ColorRole.
const QColor & QColorGroup::light () const
Returns the light color of the color group.
See also ColorRole.
Example: themes/wood.cpp.
const QColor & QColorGroup::link () const
Returns the unvisited link text color of the color group.
See also ColorRole.
const QColor & QColorGroup::linkVisited () const
Returns the visited link text color of the color group.
See also ColorRole.
const QColor & QColorGroup::mid () const
Returns the mid color of the color group.
See also ColorRole.
Examples:
const QColor & QColorGroup::midlight () const
Returns the midlight color of the color group.
See also ColorRole.
bool QColorGroup::operator!= ( const QColorGroup & g ) const
Returns TRUE if this color group is different from g; otherwise returns FALSE.
See also
QColorGroup & QColorGroup::operator= ( const QColorGroup & other )
Copies the colors of other to this color group.
bool QColorGroup::operator== ( const QColorGroup & g ) const
Returns TRUE if this color group is equal to g; otherwise returns FALSE.
See also
void QColorGroup::setBrush ( ColorRole r, const QBrush & b )
Sets the brush used for color role r to b.
See also brush(), setColor(), and ColorRole.
Example: themes/wood.cpp.
void QColorGroup::setColor ( ColorRole r, const QColor & c )
Sets the brush used for color role r to a solid color c.
See also brush() and ColorRole.
Examples:
const QColor & QColorGroup::shadow () const
Returns the shadow color of the color group.
See also ColorRole.
const QColor & QColorGroup::text () const
Returns the text foreground color of the color group.
See also ColorRole.
Example: listviews/listviews.cpp.
π RELATED FUNCTION DOCUMENTATION π
QDataStream & operator<< ( QDataStream & s, const QColorGroup & g )
Writes color group, g to the stream s.
See also Format of the QDataStream operators.
π¦ SEE ALSO π¦
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
βοΈ AUTHOR βοΈ
Generated automatically from the source code.
...and that's part 1, bestie β more is coming, don't go anywhere π
π BUGS π
okay bestie, so if you find a bug in Qt (and likeβ¦ you will, it's software, it's giving human) β please report it the way they describe at http://doc.trolltech.com/bughowto.html π Good bug reports literally help them help you. Thank you, mwah π«Ά
ngl, the definitive Qt documentation is the HTML one, no cap. It lives at $QTDIR/doc/html and you can read it with Qt Assistant or, like, a web browser, whatever vibes you prefer π This man page? It's just a little convenience for the girlies who prefer man pages β lowkey iconic of them to make it, but highkey this format is not officially supported by Trolltech. periodt π
And if you spot errors in this man page specifically β not Qt itself, just the page β please report them to qt-bugs@trolltech.com π§ and pls pls pls include the name of the manual page (qcolorgroup.3qt) and the Qt version (3.3.8) so they actually know what you're talking about π
fr fr though, reporting bugs is main character energy. do it. the maintainers will be obsessed with you β¨
and that's the whole page, babe π this lil man page came to you courtesy of Trolltech AS, dated 2 February 2007, and it's the man page for QColorGroup(3qt) β go forth and colour-group responsibly, queen ππ
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms