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. Wannafly挑战赛25 C 期望操作数 数学

    题目 题意:给你你一个数x和一个数q,x<=q,每一次可以等概率把x变成[x,q]中任意一个数,问变成q的步数的期望,输出对998244353取模,多组询问 题解:首先肯定的是,可以预处理,因为 ...

  2. 微软抛弃微软.Net了吗?Net技术的未来在哪里-浅谈微软技术路线

    winform:优点是简单易学,缺点是界面做不好看,界面适应能力很差. wpf:微软结合了显卡渲染技术推出的界面设计方式,模仿html推出了自己的xaml,winform能实现的wpf都能实现,因为w ...

  3. Android学习——碎片Fragment的使用

    一.碎片的简单用法(实现在一个活动中添加两个碎片,并让这两个碎片平分活动空间) 1.新建一个FragmentTest项目: 新建一个左侧碎片布局left_fragment.xml,代码如下:(只放置一 ...

  4. VHDL之package

    Pacakge Frequently used pieces of VHDL code are usually written in the form of COMPONENTS, FUNCTIONS ...

  5. Verilog之$sreadmemb

    1 Memories  Memories file format is shown below, the address is specified as @ <address> in he ...

  6. php生成唯一识别码uuid

    /*生成唯一标志*标准的UUID格式为:xxxxxxxx-xxxx-xxxx-xxxxxx-xxxxxxxxxx(8-4-4-4-12)*/ function uuid() { $chars = md ...

  7. Language Integrated Query

    Language Integrated Query (LINQ, pronounced "link") is a Microsoft .NET Framework componen ...

  8. BZOJ 5508: [Tjoi2019]甲苯先生的字符串 矩阵乘法_思维

    求 $f[i][j]=∑f[i−1][k]$,$'a'<=k<='z'$ . 用矩阵乘法转移一波即可. 竟然独自想出来了QAQ Code: #include <bits/stdc++ ...

  9. elasticsearch聚合函数

    计算每个tag下的商品数量 GET /ecommerce/product/_search { "aggs": {  //聚合 "group_by_tags": ...

  10. 03.IO读写-2.用with open进行文件读写

    读写文件是最常见的IO操作.Python内置了读写文件的函数,用法和C是兼容的. 读写文件前,我们先必须了解一下,在磁盘上读写文件的功能都是由操作系统提供的,现代操作系统不允许普通的程序直接操作磁盘, ...