nunoaomaia
nunoaomaia

Reputation: 21

PyQt5 - Missing close button icon in QTabBar

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?

Upvotes: 0

Views: 598

Answers (1)

BEAGLE
BEAGLE

Reputation: 343

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.

Upvotes: 0

Related Questions