Qt 无法对类型"uint8_t"的参数进行排队,即使使用 qRegisterMetaType 也是如此
Qt Cannot queue arguments of type 'uint8_t' even with qRegisterMetaType
我正在尝试发送一个使用uint8_t
作为参数的排队信号。
我收到此错误:
QObject::connect: Cannot queue arguments of type 'uint8_t'
(Make sure 'uint8_t' is registered using qRegisterMetaType().)
我添加了qRegisterMetaType<uint8_t>();
作为main()
的第一行,并且还Q_DECLARE_METATYPE(uint8_t)
添加到每个文件都包含的标头中。
我仍然收到同样的错误。这是怎么回事?是不是专门针对基本类型的一些奇怪事情,因为它适用于我的自定义类。
uint8_t
是unsigned char
的typedef
。 你可以使用Qt的typedef
来表示无符号的char:quint8
,你不需要注册它。任何具有公共默认构造函数、公共副本构造函数和公共析构函数的类或结构都可以在QMetaType
中注册。你的uint8_t
是原子的,你不需要注册它,只需在Qt中使用适当的typedef
即可。 无论如何,如果您想注册该类型以便它可以被QMetaProperty
使用,或者QueuedConnections
让它正确:
qRegisterMetaType<uint8_t>("uint8_t");
有关QtMeta
系统如何工作的更多信息,请阅读Qt的文档:doc.qt.io/qt-5/qmetatype.html
相关文章:
- 排队功能
- 使用指针在C++中排队/取消排队?
- 取消排队不适用于从双链表继承的队列类
- 我们可以在队列前面以 O(1) 时间复杂度排队一个元素吗?
- Qt 无法对类型"uint8_t"的参数进行排队,即使使用 qRegisterMetaType 也是如此
- Qt:无法对类型为"QProcess::P rocessError"的参数进行排队 - QProcess::P rocessError(FailedToStart)
- 排队或不排队以实现低延迟
- 通过排队的QT信号插槽连接发送QSHAREDPOINTERS的QVECTOR
- c++ 无效指针从空闲列表中取消排队
- 有没有办法调试排队等待对象的Qt插槽调用
- Qt 排队插槽中的枚举和枚举类
- 在标头中排队调用
- 在 c++ 中排队 推送和前端
- 如何使用 QPoint 指针成员对类进行排队和取消排队
- 如何计算排队多少个字?更智能的方式
- 如何将lambda函数排队到Qt的事件循环中?
- 队列类的取消排队方法"Aborted (core dumped)"错误
- 如何将排队添加到变量的阅读和更新中
- 可以将CruiseControl项目排队
- 通过直接连接或排队连接调用插槽的QTimer超时插槽之间的区别