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

qdarkstyle work conflict with mouseMoveEvent #320

Open
ssayno opened this issue Oct 10, 2022 · 1 comment
Open

qdarkstyle work conflict with mouseMoveEvent #320

ssayno opened this issue Oct 10, 2022 · 1 comment

Comments

@ssayno
Copy link

ssayno commented Oct 10, 2022

Describe your Environment

  • Mac Os
  • python 3.10
  • Doom Emacs
  • PyQt5

QApplications

I want to customize my title bar, so I rewrite mousePressEvent and mouseMouseEvent function, it works fine, but after app.setStyleSheet(qdarkstyle.load_sytlesheet_pyqt5(), it will move when the app ui get focus.(I don't find a good software to get the process of this program, but I will give the MWE behind)

Code

#!/usr/bin/env python3
import sys
from PyQt5.QtCore import QPoint
import qdarkstyle
from PyQt5.QtWidgets import QApplication, QMainWindow


class MyWindow(QMainWindow):
    def __init__(self):
        super(MyWindow, self).__init__()
        self.resize(500, 600)

    def mousePressEvent(self, event):
        self.oldPos = event.globalPos()
        return super().mousePressEvent(event)

    def mouseMoveEvent(self, event):
        if not hasattr(self, 'oldPos'):
            self.oldPos =  event.globalPos()
        else:
            delta = QPoint(event.globalPos() - self.oldPos)
            self.move(self.x() + delta.x(), self.y() + delta.y())
            self.oldPos = event.globalPos()
        return super().mouseMoveEvent(event)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    # comment it or not to set the difference
    app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
    mywindow = MyWindow()
    mywindow.show()
    sys.exit(app.exec_())
@M4RKUS28
Copy link

M4RKUS28 commented Dec 2, 2022

Describe your Environment
Windows
c++17
Qt5

I used this Stylesheet in my C++ QCreator Application. Everythink works fine except the MousemoveEvent. If I use this stylesheet enabled, the mousemove event is called all the time, if it is not enabled i have to press the mousebutton in the window to get an mouse event - as i want. The bigger problem of this is, that this leads to a high cpu usage - one core is all the time at 100% usage.

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

2 participants