Clickable Event On QLabel In Python Using Pyqt4?
I am working in python GUI using pyqt4 library and new with signal and slots. I don't know how to put event on label name QPLabel. Here is my code : class Ui_Form(object): def
Solution 1:
Update the following line:
QtCore.QObject.connect(self.QPLabel, QtCore.SIGNAL(_fromUtf8("clicked()")), self.doSomething)
To:
self.QPLabel.mousePressEvent = self.doSomething
and add the event
parameter to doSomthing
...
def doSomething(self, event):
...
Solution 2:
QLabel
doesn't have a signal clicked
, so you can do one of the following:
A) Derive a custom class from QLabel
implementing handlers for mouse events.
B) Implement the event handlers in Ui_Form
, using standard QLabels
and install the form as an event filter for the labels (self.QPLabel.installEventFilter (self)
).
Post a Comment for "Clickable Event On QLabel In Python Using Pyqt4?"