QObject::connect: Cannot queue arguments of type 'QList<RootNode>' (Make sure 'QList<RootNode>' is

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

1 开发环境

Win10(64bit)

Qt5.4.2(64bit)

2 错误描述

在不同线程之间通过信号/槽来传递自定义数据类型QList<RootNode>的时候,提示错误:

[plain] view plain copy 在CODE上查看代码片派生到我的代码片
QObject::connect: Cannot queue arguments of type ‘QList’
(Make sure ‘QList’ is registered using qRegisterMetaType().)
在同一个线程中传递上述类型是没有错误的。
3 解决方法

根据参考资料[1]的提示,先包含头文件:

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
#include
然后注册自定义类:
[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
qRegisterMetaType<QList>(“QList”);
注意:其实自定义的类型只是RootNode而已,QList是Qt自带的类型。由于信号/槽中使用到const QList&类型的参数,因此需要注销QList类型!

Qt 在子线程调用文本框 appendPlainText/appendText时出错 QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType().) 阅读详情

相关推荐

QT解决报错registered using qRegisterMetaType()

注意,不是在定义类型,或者定义结构体的地方进行注册,而是在所需要用到的类的构造函数中进行注册,比如我的一个自定义类,需要用到自定义的结构体做信号参数,就在他的构造函数中注册一下。在qt日常使用中,信号与槽机制是绝对不可或缺且常用的,其中的参数一般都会比较简单,bool、int、QString之类的,但当我们想要传递相对比较复杂的参数,例如。原因大概就是信号槽的参数不支持你自定义的类型,只能识别QT库中最基本的类型参数,所以需要对自定义类型进行注册。注册完就不会报错,能够正常使用了。

Larry_Yanan的博客 6766

【Qt问题】QObject::connect: Cannot queue arguments of type ‘QVector<int>‘(Make sure ‘QVector<int>‘

在qt日常使用中,信号与槽机制是绝对不可或缺且常用的,其中的参数一般都会比较简单,bool、int、原因是因为在线程间QVector没有注册。之类的,但当我们想要传递相对比较复杂的参数,例如。,以及一些我们自定义的结构体时,就会出现报错。

Fanjufei的博客 1948

报错 QObject::connect: Cannot queue arguments of type

确保这种问题的核心是类型未注册为 Qt 的元类型。在代码中注册类型(使用声明模板类型。确保跨线程信号槽连接时使用的参数是 Qt 能识别的类型。通过以上步骤可以彻底解决这个问题,使在信号槽中正常传递,无论是在单线程还是多线程环境中。

weixin_52243202的博客 1115

PyQt报错 QObject::connect: Cannot queue arguments of type ‘QTextCursor‘

解决PyQt中QObject::connect: Cannot queue arguments of type 'QTextCursor'的问题

hubing_hust的专栏 2万+

Make sure ‘QTextCursor‘ is registered using qRegisterMetaType()

elif chk_3 == 0 and chk_4 == 2 and chk_5 == 0: # chk3 内容,chk4 时间,chk5日期。elif chk_3 == 0 and chk_4 == 0 and chk_5 == 2: # chk3 内容,chk4 时间,chk5日期。elif chk_3 == 2 and chk_4 == 0 and chk_5 == 0: # chk3 内容,chk4 时间,chk5日期。if com_input: # 如果读取结果非空,则输出。

nc006282的专栏 958

Qt-----[QTextCursor需要注意的问题]

报错信息为: QObject::connect: Cannot queue arguments of type ‘QTextCursor’ (Make sure 'QTextCursor' is registered using qRegisterMetaType().) 原因:多线程情况下连接的信号槽没有指定方式。 解决方法:指定Qt::QueuedConnection方式 QObj...

github_35960067的博客 4220

Qt篇——QObject::connect: Cannot queue arguments of type ‘xxx‘(Make sure ‘xxx‘ is registered using qReg

Qt开发中,在尝试触发某个信号时程序崩溃, 发现报错提示QObject::connect: Cannot queue arguments of type 'xxx'(Make sure 'xxx' is registered using qRegisterMetaType().)。

u011391361的博客 2458

QObject::connect: Cannot queue arguments of type "xxx"的解决方案

问题描述 在跨线程的信号和槽的参数传递中, 参数的类型是自定义的类型, 然而此时出现了错误: QObject::connect: Cannot queue arguments of type 'Pos' (Make sure 'Pos' is registered using qRegisterMetaType().) 其中, Pos是自定义的类型: struct Pos { int x...

Erick Lv的笔记 1万+

Qt QObject::connect: Cannot queue arguments of type ‘uint16_t‘

QObject::connect: Cannot queue arguments of type 'uint16_t' (Make sure 'uint16_t' is registered using qRegisterMetaType().) 网上很多说遇到这种情况是由于数据结构是自定义类型,但uint16_t这个一般编译器已经帮我们定义好了,而且在非跨线程情况下都是可以用的。 但是我还是觉得可以尝试使用qint16来替代uint16_t试试,后来又在网站上看到别人的回答,更确定我的想法应该可以完

lxj362343的博客 1353

QObject::connect: Cannot queue arguments of type 'QTextCursor'

使用PyQt5编写UI程序的时候,发现运行时会经常蹦出这句提示,经检查发现该错误出现程序写入QtextEidt组件时产生的信息。 经搜索后发现当使用QTextEdit,并使用了append方法就会出现该错误提示,原因是我们不能通过线程来修改UI,较为安全的修改用户界面的方式是向UI窗口发送信号(signal),较为简单的方式是使用 Qt threading类。 class MyThread(QtC...

时有限 7933

Qt编译报错QObject::connect: Cannot queue arguments of type ‘xxxxxx‘

Qt编译报错QObject::connect: Cannot queue arguments of type 'xxxxxx'

菜鸡正在学习 1999

QObject::connect: Cannot queue arguments of type ‘QVector<int>‘ (Make sure ‘QVector<int>‘ is registe

QObject::connect: Cannot queue arguments of type ‘QVector’ (Make sure ‘QVector’ is registered using qRegisterMetaType().) 原因: qRegisterMetaType 未注册 QVector 解决方法: #include <QMetaType> qRegisterMetaType<QVector<int>>("QVector<int>");

qq_42027094的博客 9788

QObject::connect: Cannot queue arguments of type 'QString&'的解决方法

[Qt]QObject::connect: Cannot queue arguments of type 'QString&'的解决方法 在主线程和子线程中,通过信号与槽发送QString,遇到 QObject::connect: Cannot queue arguments of type 'QString&'问题 错误代码: connect(this,SIGNAL(emStar...

Y_Hanxiao的博客 2813

QObject::connect: Cannot queue arguments of type...【已解决】

问题: Qt程序编译出现如下问题: QObject::connect: Cannot queue arguments of type 'QList<quint16>' (Make sure 'QList<quint16>' is registered using qRegisterMetaType().) 这个是由于,在主线程中开启另一个线程,这两个线程之间需要进行信息的交互。但是QList<quint16>l类型没有被注册,只要你注册一下就解决了。 解决方法:

www.linuxkiss.com 你可以精通一门IT技术 1万+

20200306-01 QObject::connect: Cannot queue arguments of type 'QQmlChangeSet'

一、问题报错 QObject::connect: Cannot queue arguments of type 'QQmlChangeSet' (Make sure'QQmlChangeSet' isregistered using qRegisterMetaType() 二、问题发生的前因 我在 boost 回调函数中使用了 beginInsertRows 这类更新 Tablevi...

你学习了吗?咋办,先想法子忽悠成“砖家”呗 1038

Qt QObject::connect: Cannot queue arguments of type ‘***’

这个问题在win的没有太注意有没有这个问题,但是切刀Linux下,看到,那就解决了他。

DreamLife 1101

【Qt QObject::connect: Cannot queue arguments of type ‘your class‘】

在Qt框架中,如果你需要在QObject派生类的信号(signals)或槽(slots)机制中传递自定义类型的数据,或者需要将这些数据存储在QObject的属性(properties)中,你需要确保这些类型已被注册,以便Qt的元对象系统能够识别和处理它们。函数用于注册一个自定义类型,使其可以在Qt的元对象系统中使用。这包括在跨线程的信号和槽通信中传递该类型的实例,或者在Qt属性系统中使用。如果你在代码中看到这样的提示(可能来自Qt Creator的编译器插件或静态分析工具),这意味着你的代码中使用了类型。

一起学习进步! 804

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

今天线程传值中传容器发现子线程给主线程发信号的时候报错了,出现QObject::connect: Cannot queue arguments of type '******',该信息通过注册类型来解决容器传输报错的问题。 本文作者原创,转载请附上文章出处与本文链接。 原因:因为该传输类型信号没有定义,不像QString、int等等常见类型直接发信号就可以。 解决方法:定义一个该类型。 示例: mainwindow.h void colle...

断点 8170

Qt出现错误QObject::connect: Cannot queue arguments of type 'QUuid'(Make sure 'string' is reg //QObject::...

转自CSDN:https://blog.csdn.net/qq575787460/article/details/8469240 例如以C++标准库中string做参数,则会出现: QObject::connect: Cannot queue arguments of type 'string' (Make sure 'string' is registed using qRegisterM...

weixin_30716141的博客 537
上一篇: QObject::connect: Cannot queue arguments of type 'QTextBlock' (Make sure 'QTextBlock' is registered
下一篇: 高格VE8产品技术白皮书
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蜀山量化策略程序

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值