PyQt 自定义信号带参数 emit

PyQt5 自定义信号带参数

import sys
from PyQt5.QtCore import pyqtSignal, QObject
from PyQt5.QtWidgets import QMainWindow, QApplication

class mysignal(QObject):
    closeApp = pyqtSignal(list)

class Example(QMainWindow):

    def __init__(self):
        super().__init__()
        self.c = mysignal()
        self.c.closeApp.connect(self.myclose)
        self.show()

    def mousePressEvent(self, event):
        hehe = list(range(10))
        self.c.closeApp.emit(hehe)

    def myclose(self, mylist):
        print(mylist)
        self.close()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

 

 

REF

https://www.cnblogs.com/codeAB/p/5029133.html

 

posted @ 2022-01-16 20:28  emanlee  阅读(701)  评论(0编辑  收藏  举报