Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a theme enables mouseTracking in QTabBar #232

Open
ptsavol opened this issue Feb 2, 2023 · 0 comments
Open

Setting a theme enables mouseTracking in QTabBar #232

ptsavol opened this issue Feb 2, 2023 · 0 comments

Comments

@ptsavol
Copy link

ptsavol commented Feb 2, 2023

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:

  1. Run the example app below
  2. Hover mouse over the tabs (label1 or label2) and you will see a bunch of prints MoveEvent mouseTracking:True
  3. Close the example app
  4. Comment line `qdarktheme.setup_theme()
  5. Run the example app again
  6. Hover mouse over the tabs and no prints appear
  7. 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant