Python 自定义label clicked
class MyQLabel(QtWidgets.QLabel): # 自定义信号, 注意信号必须为类属性 clicked = QtCore.pyqtSignal() def __init__(self, parent=None): super(MyQLabel, self).__init__(parent) def mouseReleaseEvent(self, QMouseEvent): self.clicked.emit() # 可在外部与槽函数连接 def connect_customized_slot(self, func): self.clicked.connect(func)