QObject::connect: Cannot queue arguments of type "xxx",(Make sure "xxx" is registed using qRegisterM
来源:互联网 发布:公文流转软件 编辑:程序博客网 时间:2024/06/03 04:04
在线程中通过信号和槽函数传递信息的时候,由于用到了自己定义的参数结构:QHash<int , pMsg>,于是在发生信号传递的时候出现了报错:
QObject::connect: Cannot queue arguments of type "QHash<int , pMsg>",(Make sure "QHash<int ,pMsg>" is registed using qRegisterMetaType().)
查找到原因为:
线程中信号和槽函数的传递,参数是默认放到队列中去的,但是这个自定义的参数结构,不是QT自带的参数结构,不能识别。
解决方法有两点:
(1)将不识别的参数结构进行注册,让QT能够识别。
A 包含头文件:#include <QMetaType>
B 在构造的类的构造函数中调用其方法完成注册:qRegisterMetaType< QHash<int , pMsg> >("QHash<int , pMsg>");
(2)直接调用对方槽函数,不保存参数,直接传递。
connect(pLink->module,SIGNAL(sendReportToMainWithHash(QHash<int,pMsg>,QString)),this,SLOT(receiveReportFromIecServiceWithHash(QHash<int,pMsg>,QString)), Qt::DirectConnection);
此种方法未测试,且官方认为这样做有风险,不推荐。
阅读全文
0 0
- QObject::connect: Cannot queue arguments of type "xxx",(Make sure "xxx" is registed using qRegisterM
- QObject::connect: Cannot queue arguments of type 'XXX'
- Qt: QObject::connect: Cannot queue arguments of type 'XXX'
- 信号槽传递非Qt库类型参数时,出现QObject::connect: Cannot queue arguments of type 'QUuid'(Make sure 'string' is regi
- QObject::connect: Cannot queue arguments of type
- [Qt]QObject::connect: Cannot queue arguments of type 'QString&'
- 关于QObject::connect: Cannot queue arguments of type"..."
- 关于QObject::connect: Cannot queue arguments of type"..."
- QObject::connect: Cannot queue arguments of type 'cv::Mat'
- QObject::connect: Cannot queue arguments of type 'string'
- QObject::connect: Cannot queue arguments of type 'QList<QMap<QString,QString> >'
- QObject::connect: No such slot xxx错误
- QObject::connect: No such slot xxx错误
- Qt:QtQuick Cannot queue arguments of type 'QQmlChangeSet'
- [真理永垂不朽]The method XXX in the type FragmentTransaction is not applicable for the arguments XXX
- 有关 flex.messaging.MessageException: Cannot create class of type 'XXX'. Type 'XXX' not found.
- The type java.xxx.Xxx cannot be resolved. It is indirectly referenced from required.class
- make xxx Is a directory
- 简单存储过程的编写
- java日期格式中MMM的问题
- HttpClient
- Python + opencv 实现图片马赛克
- log4net 使用笔记(c# .net framework)
- QObject::connect: Cannot queue arguments of type "xxx",(Make sure "xxx" is registed using qRegisterM
- 神奇的Invalid bound statement (not found)错误
- vector map set的使用
- PAT (Advanced Level) Practise1134Vertex Cover (25)
- CentOS中安装setup工具
- leetcode-cli的安装与使用以及未解决的问题
- 数据分析师:大数据建模,你需要了解九大形式
- equals与==
- SQL Server 修改兼容模式