Unsolved Enum class sample
-
Hi!
I would like to use an enum class, this is in an included header:
class Ble: public QObject { Q_OBJECT public: enum Message { hubproperty = 0x01, hubattachedio = 0x04, hwnetworkcommand = 0x08, portinputformat = 0x41, portvalue = 0x45 }; Q_ENUM(Message) };
The compiler give this error:
undefined reference to `Ble::staticMetaObject'
Thanks in advance
-
This post is deleted! -
Same result
-
#include <QObject> class Ble { Q_GADGET public: enum Message { Hubproperty = 0x01, Hubattachedio = 0x04, Hwnetworkcommand = 0x08, Portinputformat = 0x41, Portvalue = 0x45 }; Q_ENUM(Message) };
-
QObject included the top of header file
-
@Kutyus did you noticed the other changes in my post?
-
Ohh Q_GADGET :) I will try
-
-
Same error :(
-
@J-Hilk This error is produced by linker, in the object file, where is this line:
QMetaEnum::fromType<Ble::Message>().valueToKey(m)
m is a message code integer.
-
@Kutyus
https://github.com/DeiVadder/Topic109331working class
-
@Kutyus said in Enum class sample:
QMetaEnum::fromTypeBle::Message().valueToKey(m)
When I comment out the line wich contains the QMetaEnum::fromTypeBle::Message().valueToKey(m), the code is compiled succes.
How can i get the enum name from its value?