QT Control Color Panel class Qpalette (go from csdn,xgbing)

Source: Internet
Author: User

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
    1. Qpalette palette = Widget->palette ();
    2. Palette.setcolor (Qpalette::window, Qt::lightgray); //change control background color
    3. Palette.setcolor (Qpalette::windowtext, Qt::blue); //Change control font Color
    4. ...
    5. 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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.