Enum class sample
-
wrote on 29 Nov 2019, 13:07 last edited by
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
-
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
wrote on 29 Nov 2019, 13:10 last edited by ODБOïThis post is deleted! -
wrote on 29 Nov 2019, 13:24 last edited by
Same result
-
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
#include <QObject> class Ble { Q_GADGET public: enum Message { Hubproperty = 0x01, Hubattachedio = 0x04, Hwnetworkcommand = 0x08, Portinputformat = 0x41, Portvalue = 0x45 }; Q_ENUM(Message) };
-
wrote on 29 Nov 2019, 13:33 last edited by
QObject included the top of header file
-
@Kutyus did you noticed the other changes in my post?
-
wrote on 29 Nov 2019, 13:39 last edited by
Ohh Q_GADGET :) I will try
-
-
wrote on 29 Nov 2019, 13:50 last edited by
Same error :(
-
wrote on 29 Nov 2019, 13:54 last edited by
@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.
-
@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
-
wrote on 29 Nov 2019, 14:09 last edited by
@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?
1/12