简体   繁体   English

PyQt5 Tabwidget 标签栏空白区域背景色

[英]PyQt5 Tabwidget tab bar blank area background color

在此处输入图片说明

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.我检查了这个链接: 如何更改 qtabbar 空白空间 pyqt 的背景颜色,但没有成功。

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 .这取决于documentMode

If it's False (the default), you have to set the TabWidget background, and ensure that its autoFillBackground() is set to True;如果为False (默认),则必须设置TabWidget 背景,并确保其autoFillBackground()设置为True; this is very important, as Qt automatically unselect it when setting a stylesheet.这非常重要,因为 Qt 在设置样式表时会自动取消选择它。
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;
        }
    ''')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM