The Qtabwiget class in Qt provides a sticky note control, but the default initialization color of this control is white, and the color of the original window looks very vainly disobey, so we want to set its background color to the background color of the current window. All we have to do is remove the background color of the application window and assign it to each label of the Qtabwiget class, for example, we have the TAB1 and tab2 two tags, to change the background color can be as follows code:
Ui.tab1->setpalette (qwidget::p alette (). Color (This->backgroundrole ())); Ui.tab1->setautofillbackground ( true); Ui.tab2->setpalette (qwidget::p alette (). Color (This->backgroundrole ()));ui.tab2-> Setautofillbackground (TRUE);
If you want to change to a specific color, such as green, you can use the following code:
Ui.tab1->setpalette (* (New Qpalette (Qt::green))); Ui.tab1->setautofillbackground (true);
Http://www.cnblogs.com/grandyang/p/4304624.html
Qtabwiget Change color changes colors (each qwidget has its own palette palette, sets its color, and then Setautofillbackground)