PDA

View Full Version : Styling tabs on tabWidget



kode
14th December 2010, 11:35
Hi all,

I am trying to customize tabs on a tabWidget. I make so far


QString styleTabs;
styleTabs.append("QTabBar::tab { width:120px; height:30px; color:#333399; font-family:Tahoma; font-size:14px; font-weight:bold; }");
styleTabs.append("QTabBar::tab:hover { border-top:2px solid #E68B2C; margin-top:-1px; }");
ui->tabWidget->setStyleSheet(styleTabs);

The problem is when I hover the properties are lost. I.e. my selected tab is white. When I hover it the background:white property is lost and the tab become gray. I want to inherit the properties somehow. How can I do that?

The other thing I want to do is to change the background color of all tabs that are not active. How can I match them?

And the third thing is to put background image on some element. I try


QString styleButton2;
styleButton2.append("QPushButton { background-image:url('icon.png'); background-repeat:none; background-position:top left; }");
ui->pushButton_2->setStyleSheet(styleButton2);

The image is in the same folder as the project, header and c++ files.

high_flyer
14th December 2010, 12:19
The stylesheet you set with setStyleSheet() is the stylesheet that will be set for the widget, any previous style-sheets will be lost.
It must contain everything you want, including the white background.


The other thing I want to do is to change the background color of all tabs that are not active.
What do you mean by not active? disabled or just with out focus?

kode
15th December 2010, 15:14
What do you mean by not active? disabled or just with out focus?

I mean with out focus. I managed that with tab for all and tab.selected for the active tab.