PyQt5: Can't see close buttons in QTabBar

痞子三分冷 提交于 2021-01-27 12:04:37

问题


I can't see the close button on individual tabs when using PyQt5. I can close the individual tabs when I click where I know the close button should be, but can't see the button outright:

#!/bin/python3
import sys
from PyQt5.QtWidgets import (QApplication, QVBoxLayout,
                            QTabBar, QFrame)

class App(QFrame):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Web Browser")
        self.setBaseSize(683, 384)
        self.CreateApp()

    def CreateApp(self):
        self.layout = QVBoxLayout()
        self.tab_Bar = QTabBar(movable=True, tabsClosable=True)
        self.tab_Bar.tabCloseRequested.connect(self.CloseTab)

        self.tab_Bar.addTab("Tab 1")
        self.tab_Bar.addTab("Tab 2")

        self.tab_Bar.setCurrentIndex(0)

        self.layout.addWidget(self.tab_Bar)
        self.setLayout(self.layout)
        self.show()

    def CloseTab(self, i):
        self.tab_Bar.removeTab(i)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = App()

    sys.exit(app.exec_())

I'm using Python version 3.6.2 and PyQt5 version 5.9

来源:https://stackoverflow.com/questions/46104347/pyqt5-cant-see-close-buttons-in-qtabbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!