I want that if I move my mouse over the label with text stop on it then it should change the value of a variable Stop to True so that I may pause/stop my program.
I have looked the code at Mouseover event filter for a PyQT Label and tried to run it, but nothing is being shown up.
The code is:
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5 import *
import sys
class mouseoverEvent(QtCore.QObject):
def __init__(self, parent):
super(mouseoverEvent, self).__init__(parent)
self.initUI()
def eventFilter(self, object, event):
if event.type() == QtCore.QEvent.MouseMove:
print( "mousemove!")
return True
else:
return False
def initUI(self):
self.filter = mouseoverEvent(self)
self.label.installEventFilter(self.filter)
self.lbl=QLabel(self)
self.lbl.setText(self,"hellojjj")
self.setGeometry(1000, 30, 300, 100)
self.setWindowTitle('QLineEdit')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = mouseoverEvent()
sys.exit(app.exec_())