Styling tab background in QTabWidget
-
As you can see in this screenshot I styled QTabWidget but I couldn't set tab's background to transparent although I used:
[code]QTabWidget#tabWidget_sidebar {
background-color: rgba(255, 255, 255, 0);
}[/code]How can I fix this issue?
!http://img692.imageshack.us/img692/3221/yexf.png(QTabWidget stylesheet)!
The complete QSS of QTabWidget:
[code]QMainWindow#MainWindow {
background-image: url(:/theme/bg.jpg);
}QWidget#centralWidget {
background-color: rgba(255, 255, 255, 0);
}
/**************** SIDE BAR ****************/
QTabWidget#tabWidget_sidebar {
background-color: rgba(255, 255, 255, 0);
}QTabWidget#tabWidget_sidebar::tab-bar {
alignment: center;
}QTabWidget#tabWidget_sidebar::pane {
background-color: rgb(255, 255, 255, 0);
}QTabBar::tab {
background-color: rgb(0, 0, 0, 0);
padding: 2px;
border: 2px;
text-align: center;
height: 64px;
width: 64px;
}QTabBar::tab:selected {
background-color: rgba(255, 255, 255, 100);
}QTabBar::tab:hover {
background-color: rgba(255, 255, 255, 150);
}
[/code] -
Hi,
Did you also
@widget->setAttribute(Qt::WA_TranslucentBackground);@
?
-
Is your QTabWidget contained in another widget ? And what do you expect to see through it (i.e. desktop, other program window etc...) ?
-
[quote]Is your QTabWidget contained in another widget ?[/quote]
It contained in MainWindow directly.[quote]And what do you expect to see through it (i.e. desktop, other program window etc…) ?[/quote]
As shown in the screenshot I expect to see transparent tab (see the wood instead of gray color) -
Then try this:
@
QStackedWidget *stack = tabWidget->findChild<QStackedWidget *>();
stack->setStyleSheet("background-color: rgba(255, 255, 255, 0)");
@ -
add
@stack->setAttribute(Qt::WA_TranslucentBackground);@
-
I created a repository contains on demo application for testing QTabWidget stylesheet and I added you as a moderator: https://github.com/mbnoimi/test
May you please see what's going on?
-
Your example is missing the stylesheet/background/icons to reproduce what you show in your first post.
-
[quote author="SGaist" date="1378155444"]Your example is missing the stylesheet/background/icons to reproduce what you show in your first post.[/quote]
It doesn't missing anything. I created very simple project so may you please run the project to test your suggestions.
-
If you'd like me to test anything related to your widget styling problem, I'll need a complete example with the style sheet your are using and the necessary elements for it (i.e. the background / icons)
-
[quote author="SGaist" date="1378157197"]If you'd like me to test anything related to your widget styling problem, I'll need a complete example with the style sheet your are using and the necessary elements for it (i.e. the background / icons)[/quote]
OK; I updated a new version with resources (modified the screenshot)
-
-
Then... The first question that should have been asked: What version of Qt/OS are you using ?