clickable event on QLabel in python using pyqt4?

后端 未结 2 2055
名媛妹妹
名媛妹妹 2021-02-07 10:02

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 :



        
2条回答
  •  没有蜡笔的小新
    2021-02-07 10:29

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

提交回复
热议问题