ColinDuquesnoy / QDarkStyleSheet

A dark style sheet for QtWidgets application
Other
2.76k stars 725 forks source link

qdarkstyle work conflict with mouseMoveEvent #320

Open ssayno opened 1 year ago

ssayno commented 1 year ago

Describe your Environment

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 commented 1 year ago

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.