[Development] QML: Why C++11 scoped enums are not scoped in QML?

BogDan Vatra bogdan at kdab.com
Tue Jul 26 19:08:30 CEST 2016


On marți, 26 iulie 2016 08:33:31 EEST Thiago Macieira wrote:
> Em terça-feira, 26 de julho de 2016, às 17:50:38 PDT, BogDan Vatra escreveu:
> > Hi,
> > 
> > Is there any reason why C++11 scoped enums are not scoped in QML ?
> 
> There's no trait to tell apart a scoped enum from an unscoped one. An enum
> is en enum, that's all.
> 

scoped enums are declared differenty : enum *class* MyEnum :) 
Even more, scoped enums in C++ must me used with fully qualified name *MyEnum a 
= MyEnum.Val1* not *MyEnum a = Val1*, so a scoped enum is not exacly an enum 
:)

> If you want a given enum to be scoped in QML, it should be a QML engine
> feature and should be available to any C++ enum, whether it's scoped or not.

> > If I have something like the following code in C++
> 
> [cut]
> 
> >  Q_ENUM(MyEnum)
> 
> This is all the engine sees. It's an enum.

Well, that's all the *moc* sees and I'm pretty sure it knows also the *class* 
keyword, otherwise it can't skip it properly...

Cheers,
BogDan.




More information about the Development mailing list