使用QT5新语法写信号/槽连接:
比如:
connect(Device::getInstance(), &Device::sig_sendData, this, &Tool::slot_receiveData);
此时:
sig_sendData(QString, uint32_t);
slot_receiveData(QString, uint32_t);
一段时间后:
有人改了信号函数的参数类型,变成了:
sig_sendData(QString, QByteArray);
于是编译报错:
“Signal and slot arguments are not compatible.”
从报错这里知道是信号槽函数参数不匹配的问题,但是不知道是哪个信号槽函数的参数不匹配,编译器并没有定位到具体信号槽连接。
找了好久才找到具体的信号槽函数。
突然觉得有参数的信号槽函数连接用旧语法比较好,修改参数时会直接在信号槽的连接处报错。
connect(Device::getInstance(), SIGNAL(sig_sendData(QString,uint32_t)), this, SLOT(slot_receiveData(QString, uint32_t));
QT编译报错:“Signal and slot arguments are not compatible.”
原文:https://www.cnblogs.com/grebamboo/p/13958631.html