PyQtDarkTheme
PyQtDarkTheme copied to clipboard
Setting a theme enables mouseTracking in QTabBar
Windows 10, Python 3.11, PySide 6.4.1, pyqtdarktheme 2.1.0
Problem: Enabling a theme with qdarktheme.setup_theme()
enables mouseTracking for QTabBars.
Steps to reproduce:
- Run the example app below
- Hover mouse over the tabs (label1 or label2) and you will see a bunch of prints
MoveEvent mouseTracking:True
- Close the example app
- Comment line `qdarktheme.setup_theme()
- Run the example app again
- Hover mouse over the tabs and no prints appear
- Click on tab label1 or label2 and a print appears
PressEvent mouseTracking:False
Expected behaviour: Mouse tracking in QTabBar should be disabled when a theme is enabled.
Here's the example app.
import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QTabWidget, QTabBar, QVBoxLayout, QWidget, QLabel
import qdarktheme
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setFixedSize(400, 300)
tab_widget = QTabWidget(self)
tab_bar = CustomTabBar(self)
tab_widget.setTabBar(tab_bar)
push_button = QPushButton("PyQtDarkTheme!!")
tab1 = QLabel("abc")
tab2 = QLabel("def")
tab_widget.addTab(tab1, "label1")
tab_widget.addTab(tab2, "label2")
self.layout = QVBoxLayout()
self.layout.addWidget(tab_widget)
self.layout.addWidget(push_button)
self.container = QWidget()
self.container.setLayout(self.layout)
self.setCentralWidget(self.container)
class CustomTabBar(QTabBar):
def __init__(self, parent):
super().__init__(parent)
def mousePressEvent(self, event):
print(f"PressEvent mouseTracking:{self.hasMouseTracking()}")
super().mousePressEvent(event)
def mouseMoveEvent(self, event):
print(f"MoveEvent mouseTracking:{self.hasMouseTracking()}")
super().mouseMoveEvent(event)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
# Apply dark theme.
qdarktheme.setup_theme() # Comment this line
app.exec()