[SOLVED]QTabBar stylesheet
-
How can I specify id for QTabBar in stylesheet?
Example:
@
QTabWidget#tabWidget_sidebar {
background-color: rgba(0, 0, 255, 255);
}/***** ERROR *****/
QTabBar#tabWidget_sidebar::tab {
background-color: rgb(255, 0, 0);
padding:5px;
border: 10px;
text-align: center;
height:64px;
width:64px;
}@ -
Hi,
Are you searching for "this":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar ?
-
Just to be sure, did you set your widget name with setObjectName ?
-
Because the name is set to the QTabWidget not the QTabBar from the QTabWidget
-
I don't remember if designer allows to name sub-control widgets, you would have to try that.
Or you could use the tab-bar subcontrol in your style sheet
-
[quote]I don’t remember if designer allows to name sub-control widgets, you would have to try that.[/quote]
Unfortunately Qt Designer doens't allow to name sub-controls (I'll file a feature request) so I fixed this issue by calling this in the constructor:
[code]ui->tabWidget_sidebar->tabBar()->setObjectName("tabBar");[/code]And used the following stylesheet:
[code]QTabBar#tabBar::tab {
background-color: rgb(0, 0, 0, 0);
padding: 2px;
border: 2px;
text-align: center;
height: 64px;
width: 64px;
}QTabBar#tabBar::tab:selected {
background-color: rgba(255, 255, 255, 100);
}QTabBar#tabBar::tab:hover {
background-color: rgba(255, 255, 255, 150);
}[/code]Thank you SGaist
-
I post a suggestion in:
https://bugreports.qt-project.org/browse/QTBUG-33159 -
You're welcome !
Then why not use the tab-bar sub control keyword in the stylesheet ?