當(dāng)前位置:首頁 > IT技術(shù) > 其他 > 正文

PyQt5 帶參數(shù)信號傳遞
2022-05-31 17:27:37

################################
# PyQt5中文網(wǎng) - PyQt5全套視頻教程 #
#    https://www.PyQt5.cn/     #
#         主講: 村長            #
################################

from PyQt5.Qt import *

class MySignal1(QObject):
    sendmsg = pyqtSignal([str], [str, int])

    def send_msg(self):
        self.sendmsg[str, int].emit('hello', 2)
        self.sendmsg[str].emit('hello')

class Myslot1(QObject):
    def get_msg(self, str, a):
        print('你好' + str)
        print(a)


mysignal1 = MySignal1()
myslot1 = Myslot1()
mysignal1.sendmsg[str, int].connect(myslot1.get_msg)
# mysignal1.sendmsg[str].connect(myslot1.get_msg)
mysignal1.send_msg()

?

本文摘自 :https://www.cnblogs.com/

開通會員,享受整站包年服務(wù)立即開通 >