The Qpalette class provides the color used when drawing qwidget controls.
The color state of the control is divided into three types:
(1) Active, activation state
(2) Disabled, disabling state
(3) Inactive, not active
The control has different color values in these three different states, and the Qpalette class manages the three sets of colors, which are divided into three groups of colors based on these three states, and each group of colors is categorized according to the different drawing roles. These colors are used by the system when drawing controls, and programmers can change these settings.
The method is set to First call Qwidget::p Alette () Gets the current panel, modifies it to a custom value, and then sets it to the newly modified panel by method Qwidget::setpalette. The code looks like this:
[CPP]View Plaincopy
- Qpalette palette = Widget->palette ();
- Palette.setcolor (Qpalette::window, Qt::lightgray); //change control background color
- Palette.setcolor (Qpalette::windowtext, Qt::blue); //Change control font Color
- ...
- Widget->setpalette (palette);
This way, you can easily set the background color of the control, font color, and so on.
The usual setup methods are as follows:
(1) void Qpalette::setbrush (Colorrole role, const Qbrush & Brush)
Change the brush color value for roles assigned under all groups.
(2) void Qpalette::setbrush (Colorgroup Group, colorrole role, const Qbrush & Brush)
Changes the brush color value for the specified role under Group group.
(3) void Qpalette::setcolor (Colorrole role, const Qcolor & color)
Change the color value for role roles under all groups.
(4) void Qpalette::setcolor (Colorgroup Group, colorrole role, const Qcolor & color)
Changes the color value of the role assigned under the specified group under groups.
Next detail: http://blog.csdn.net/xgbing/article/details/7784984
QT Control Color Panel class Qpalette (go from csdn,xgbing)