see the code after subclassing
TabWidget::TabWidget(QWidget *parent): QTabWidget(parent),mousePressFlag(false)
{
bar=tabBar();
QPalette palette;
bar->installEventFilter(this);
palette.setColor(QPalette::Active,QPalette::Button ,QColor(0,0,255));
bar->setPalette(palette);
bar->setAutoFillBackground(true);
};
- TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent){
- QPalette pal = tabBar()->palette;
- pal.setColor(QPalette::Window,QColor(0,0,255));
- tabBar()->setPalette(pal);
- }
tabWidget->setPalette(QPalette(Qt::red));
http://www.qtcentre.org/threads/2986-How-to-change-color-of-Tab-in-QTabWidget
时间: 2024-10-26 22:51:07