clickable event on QLabel in python using pyqt4?

邮差的信 提交于 2019-12-03 06:04:27

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):
...

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)).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!