I'm trying to send a queued signal that uses a uint8_t
as a parameter.
I get this error:
QObject::connect: Cannot queue arguments of type 'uint8_t'
(Make sure 'uint8_t' is registered using qRegisterMetaType().)
I have added qRegisterMetaType<uint8_t>();
as the first line of main()
and I also added Q_DECLARE_METATYPE(uint8_t)
to a header that every file includes.
I still get the same error. What's up with that? Is it some weird thing specifically with basic types, because it works fine for my custom classes.
uint8_t
is the typedef
for unsigned char
.
You can use Qt's typedef
for unsigned char: quint8
and you don't need to register it. Any class or struct that has a public default constructor, a public copy constructor and a public destructor can be registered in QMetaType
. Your uint8_t
is atomic and you don't need to register it, just use proper typedef
in Qt.
Anyway if you want to register that type so it can be used by QMetaProperty
, or in QueuedConnections
just make it right:
qRegisterMetaType<uint8_t>("uint8_t");
For more information how the QtMeta
system work please read Qt's documentation for it: doc.qt.io/qt-5/qmetatype.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With