qt里的信号和槽除了可以传递行为外,还可以传递数据,这里以传递DataFrame为例
import pandas as pd
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtCore import QObject
class A(QObject):
sig = pyqtSignal(pd.DataFrame)#信号变量
def __init__(self):
super(A, self).__init__()
self.sig.connect(B.f_slot)#信号连接到槽函数
def f_sig(self, df):
#其它操作
self.sig.emit(df)#发出信号
class B(QObject):
def __init__(self):
super(B, self).__init__()
def f_slot(df):#槽函数
print(df)
a = A()
d = {'aa' : [1,2], 'bb' : ['b','b']}
df = pd.DataFrame(data = d)
a.f_sig(df)