[Interest] use old enum with Q_ENUM

Thiago Macieira thiago.macieira at intel.com
Thu Jul 14 04:45:33 CEST 2016


On quinta-feira, 14 de julho de 2016 12:04:06 PDT Hamish Moffatt wrote:
> The following doesn't work (on Qt 5.5.1 or 5.6); it compiles, but 
> object->metaObject()->enumeratorCount() reports there are none. The enum 
> values are not in the MOC output.

Here's an even uglier solution:
> #include <QObject>
> 

#ifdef Q_MOC_RUN
class NewEnumWrapper : public QObject
{
#endif

> enum OldEnum
> {
>      VAL1,
>      VAL2,
>      VAL3
> };
> 

#ifndef Q_MOC_RUN
> class NewEnumWrapper : public QObject
> {
#endif

>      Q_OBJECT
> 
> public:
>      using Enum = ::OldEnum; // also tried typedef, no change
>      Q_ENUM(Enum)
> };


-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list