I have an enum and a property in my QObject
-based class like:
Q_ENUMS(StateEnum)
Q_PROPERTY(StateEnum state READ state NOTIFY stateChanged)
When I try to emit stateChanged(state)
, I receive an error:
QObject::connect: Cannot queue arguments of type 'StateEnum'
(Make sure 'StateEnum' is registered using qRegisterMetaType().)
Why do I need to invoke qRegisterMetaType
? I thought that is what Q_ENUMS
does.
You are looking for the Q_ENUM()
macro. This replaces the now-deprecated Q_ENUMS
and will automatically register the metatype.
Your code should look like this:
Q_ENUM(StateEnum) //note the missing 'S' here
Q_PROPERTY(StateEnum state READ state NOTIFY stateChanged)