hi everyone , how to fill background color in empty space tab bar area. i checked this link: how to change background color for qtabbar empty space pyqt , but not success.
here is my stylesheet:
self.tabWidget.setStyleSheet('''
QTabBar::tab{padding: 0px;}
QTabBar::tab { height: 150px; border: 1px solid #FFFFFF;}
QTabBar::tab {background-color: rgb(34, 137, 163);color: white;}
QTabBar::tab:selected {background-color: rgb(48, 199, 184,);
color: #000000
}
QTabWidget>QWidget>QWidget{background: WHITE;}
QTabWidget>{background: WHITE;}
QTabWidget::pane {top: 0px;}
QTabWidget::tab-bar {right: 0px;}
QTabBar { background: transparent; }
''')
It depends on the documentMode
.
If it's False
(the default), you have to set the TabWidget background, and ensure that its autoFillBackground()
is set to True; this is very important, as Qt automatically unselect it when setting a stylesheet.
Note that, in this case, the background will be "around" the whole tab widget too, if don't want it, just disable the border.
self.tabWidget.setStyleSheet('''
QTabWidget {
background: magenta;
border: none;
}
QTabBar::tab {
background: green;
}
''')
If the document mode is on, instead, you can just set the background for the tab bar:
self.tabWidget.setStyleSheet('''
QTabBar {
background: magenta;
}
QTabBar::tab {
background: green;
}
''')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.