QObject::connect: Cannot queue arguments of type 'QMap<QString,QString>',(Make sure 'QMap<QString,QString>' is registered using qRegisterMetaType().).

上述错误,只有在跨线程信号传递时才会出现.  因为QMap是QT可识别的基本类型,不需要再注册元对象系统中,在同一个线程中运行没有问题.

源码:

  1. // 线程类 thread.h
  2. class Thread:public QThread
  3. {
  4. Q_OBJECT
  5. public:
  6. Thread(){}
  7. ~Thread(){}
  8. protected:
  9. virtual void run();
  10. signals:
  11. void sendMsg(const QMap<QString,QString> &msgs);
  12. }
  1. // 信号接收类 test.h
  2. Test(Thread *th):m_th(th)
  3. {
  4. // 不同线程用队列方式连接
  5. connect(m_th,SIGNAL(sendMsg(const QMap<QString,QString> &)),this,SLOT(handle(const QMap<QString,QString> &)),Qt::QueuedConnection);
  6. }

解决方案:通过qRegisterMetaType()方法注册至Metype中

  1. // thread.h
  2. typedef QMap<QString,QString> StringMap; // typedef操作符为QMap起一别名
  3. void sendMsg(const StringMap &);
  1. // test.h
  2. Test(Thread *th):m_th(th)
  3. {
  4. // 注册QMap至元对象系统
  5. qRegisterMetaType<StringMap>("StringMap");
  6. connect(m_th,SIGNAL(sendMsg(const StringMap &)),this,SLOT(handle(const StringMap &)),Qt::QueuedConnection);
  7. }
 
 
http://tcspecial.iteye.com/blog/1897006

Object::connect: Cannot queue arguments of type 'QMap<QString,QString>'(要使用qRegisterMetaType<StringMap>进行注册)的更多相关文章

  1. Qt - 错误总结 - QObject::connect: Cannot queue arguments of type 'PVCI_CAN_OBJ' (Make sure 'PVCI_CAN_OBJ' is registered using qRegisterMetaType().)

    背景:一个线程通过signal-slot发送PVCI_CAN_OBJ类型的值到主线程中, 错误提示: QObject::connect: Cannot queue arguments of type ...

  2. Qt出现QObject::connect: Cannot queue arguments of type '******'的解决方法

    一般出现这种情况都是自定义的类型进行型号槽连接的时候出现的,使用 假设自定义的类型是MyClass 使用qRegisterMetaType<MyClass>("MyClass&q ...

  3. Qt解决:Qobject::connect queue arguments of type ‘xxxx’,Make sure ‘xxxx’ is registered using qRegister

    解决方法:在调用connect之前,通过 qRegisterMetaType() 注册你connect函数里对象的类型代码如下: typedef QString CustomString;//你自己定 ...

  4. Matlab无法打开M文件的错误( Undefined function or method 'uiopen' for input arguments of type 'char)

    错误提示: Undefined function or method 'uiopen' for input arguments of type'char 解决方案: 运行命令 restoredefau ...

  5. Undefined function or method 'deploywhich' for input arguments of type 'char'

    在进行matlab和java混合编程的时候.由matlab打包,把m文件转换为jar文件.供java调用.有时在Tomcat中调用此类jar类会出现如题或者以下的错误: ??? Error using ...

  6. Qt error ------ no matching function for call to QObject::connect(QSpinBox*&, <unresolved overloaded function type>, QSlider*&, void (QAbstractSlider::*)(int))

    connect(ui->spinBox_luminosity,&QSpinBox::valueChanged, ui->horizontalSlider_luminosity, & ...

  7. Object::connect: No such slot xxx 解决方法

    在所有代码和槽函数全部写好之后,进行编译时竟然报 No such slot xxxx,奇怪 Starting E:\01_project\03_C++\key\debug\key.exe... Obj ...

  8. Object::connect: No such slot QWidget::

    出现如下错误 Object::connect: No such slot QWidget::readMyCom() in ../untitled/ConversionScreen.cpp:49 解决办 ...

  9. -bash: /bin/grep: Argument list too long和 find: Arguments to -type should contain only one letter报错处理

    由于要查找的文件太多 过滤成只找具体时间一天以内的文件 | 查找最近30分钟修改的当前目录下的.php文件 查找最近24小时修改的当前目录下的.php文件 查找最近24小时修改的当前目录下的.php文 ...

随机推荐

  1. JS函数种类详解

    1. 普通函数1.1 示例 1 2 3 function ShowName(name) {   alert(name); } 1.2 Js中同名函数的覆盖 在Js中函数是没有重载,定义相同函数名.不同 ...

  2. openssl https证书

    今天摸索了下 HTTPS 的证书生成,以及它在 Nginx 上的部署.由于博客托管在 github 上,没办法部署证书,先记录下,后续有需要方便快捷操作.本文的阐述不一定完善,但是可以让一个初学者了解 ...

  3. 爬虫之Urllib库的基本使用

    官方文档地址:https://docs.python.org/3/library/urllib.html 什么是Urllib Urllib是python内置的HTTP请求库包括以下模块urllib.r ...

  4. Oracle数据库学习1------数据库安装及客户端配置

    1.注册Oracle账户: 注册地址:https://login.oracle.com/mysso/signon.jsp 注意:注册的时候尽量使用外国的邮箱,因为使用国内的邮箱可能收不到Oracle发 ...

  5. springmvc-servlet.xml 第二种选择

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  6. window下安装git

  7. javascript中caller和callee call和apply

    Arguments : 该对象代表正在执行的函数和调用它的函数的参数. [function.]arguments[n] 参数function :选项.当前正在执行的 Function 对象的名字. n ...

  8. 【C】一些字符串处理函数

    1.复制函数 我更愿意称之为”字符串覆盖函数” a. strcpy(str1,str2); 将字符串str2 覆盖到str1上 b. strncpy(str1,str2,n); 2.拼接函数 a. s ...

  9. CBIR--Survey.C/GPU优化.Sys搭建

    一:CBIR综述:转自于wiki:http://zh.wikipedia.org/wiki/CBIR 参考链接:http://blog.csdn.net/kezunhai/article/detail ...

  10. C++:数据流和缓冲区

    (1):C++之自定义的input缓冲区 原文链接:http://hi.baidu.com/nicker2010/item/d0c4cd2a7caf27c4ddf69aeb input stream用 ...