传递参数参数多个,采用map,一直insert
前提,
//map类型
typedef QMap <unsigned int , QByteArray> Map;
//信号和槽的声明
signals:
void sigToCems(InfoMap);
void slotFromEms(Map Map);//
发射点:由事件触发
//Addr_EMS_ID Addr_EMS_STATUS 宏定义
QByteArray msg = Set_sys_Ctrl_remote(0);
Map cent_map;
cent_map.insert(Addr_EMS_ID, QByteArray((char *)&ems_id, sizeof(ems_id)));
cent_map.insert(Addr_EMS_STATUS, msg);
emit sigToCems(cent_map);
中转点:信号和槽函数为同参数
anyclass *m_pro;//anyclass是一个类,这里需要新对象,处理不通层级
m_pro = new protocal();
//括号内参数填写参数类型
QObject::connect(m_pro, SIGNAL(sigToCems(Map)), this, SLOT(slotFromEms(Map)));
处理点:解析map即可
void Cems_dev::slotFromEms(Map RecvCenterMap)
{
if(RecvCenterMap.contains(Addr_EMS_STATUS) &&
RecvCenterMap.contains(Addr_EMS_ID)){
//由于发送过来是单个字节过来,复现过来需要转内存存储大小,再解析
uint8_t emsid = *(int *)RecvCenterMap[Addr_EMS_ID].data();
QByteArray msg = RecvCenterMap[Addr_EMS_STATUS];
Send_MsgToEMS(emsid, msg);
}
}