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)

 

posted @ 2022-12-29 13:04  昊天一怪  阅读(122)  评论(0编辑  收藏  举报