Reputation: 21
I'm trying to set my tabs "Closable", however I can't see the close button icon on individual tabs when using PyQt5 and "Fusion" style:
When I set "Windows" style I can see:
I already tried to use styleSheet qtabbar button but it didn't work:
QTabBar::close-button {
image: url(close.png);
subcontrol-position: left;
}
This is my code:
#!/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__":
QApplication.setStyle('Fusion')
app = QApplication(sys.argv)
window = App()
sys.exit(app.exec_())
I'm using Python version 3.6.2 and PyQt5 version 5.10.
What could be the root cause of this problem? Maybe my system is lacking some icons in Fusion style?
Upvotes: 0
Views: 598