You need to subclass the QPushButton
class and reimplement the enterEvent
and leaveEvent
:
class Button(QPushButton):
def __init__(self, parent=None):
super(Button, self).__init__(parent)
# other initializations...
def enterEvent(self, QEvent):
# here the code for mouse hover
pass
def leaveEvent(self, QEvent):
# here the code for mouse leave
pass
You can then handle the event locally, or emit a signal (if other widgets needs to react on this event you could use a signal to notify the event to other widgets).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…