How to set the background color of a tab widget in Qt Creator?

I am using Qt Creator. In my GUI, I use a tab widget. This widget should have the same gray background color as the main window (Figure A). I did this by editing the stylesheet in Qt Designer with:

background-colour: rgb(240, 240, 240);

But now I have two new problems that I cannot solve:

  • The buttons (-> Submit) are no longer rounded.
  • The background color of the edit window has also changed to gray.

Before I changed the stylesheet, the GUI looked like Figure B.

I tried too

QPalette pal = m_pUi->tabWidget->palette();
pal.setColor(m_pUi->tabWidget->backgroundRole(), Qt::blue);
m_pUi->tabWidget->setPalette(pal);

but this only changes the color behind the tabs, and not the entire color of the entire "tab-window-surface".

Do I need to make additional style descriptions or is there a simpler solution?

Picture A - with Style Sheet

Figure A - with a style sheet

Picture B - without Style Sheet

Image B - no stylesheet

+5
2

, , :

ui->tab->setAutoFillBackground(true);

, , QTabWidget .

, .

+5

", , QTabBars. , :

QTabBar::tab 
{
    background: #48555E;
    color: white;   
    border-color: #48555E;
}

QTabBar::tab:selected, 
QTabBar::tab:hover 
{
    border-top-color: #1D2A32;
    border-color: #40494E;
    color: black;
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #C1D8E8, stop: 1 #F0F5F8); 
}

.

+1

All Articles