0

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:

enter image description here

When I set "Windows" style I can see:

enter image description here

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?

nunoaomaia
  • 21
  • 6

1 Answers1

0

Similar question can be found here. Though it does not have an official answer, there are some suggestions in comments. Do check them. Since it is working for "Windows" and not for "Fusion", can be a bug in QT5.

BEAGLE
  • 343
  • 3
  • 10
  • Yes, I already read that topic but that refers to an issue caused by QT 5.9.0 and it was fixed in 5.9.2. In my case I'm using QT 5.6.0. I was searching in https://bugreports.qt.io/ and it seems that in this version works fine. – nunoaomaia Jul 07 '20 at 14:01