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

BogDan Vatra bogdan at kdab.com
Thu Jul 28 09:32:54 CEST 2016

On miercuri, 27 iulie 2016 09:08:32 EEST Thiago Macieira wrote:
> On quarta-feira, 27 de julho de 2016 11:47:03 PDT BogDan Vatra wrote:
> > On miercuri, 27 iulie 2016 10:35:01 EEST André Somers wrote:
> > > Op 27/07/2016 om 09:53 schreef BogDan Vatra:
> > > Would that not break existing QML applications that now use enums backed
> > > by scoped enums in C++?
> > 
> > It will, but personaly I can't see a better solution ...
> I have already said what to do: make it an opt-in on registration of the
> enum to the QML/JS engine.

Got it  :)

> > So, either we break the existing QML apps that used scoped enums in C++
> > (which is useless, because in QML side you'll get name clashing) or we
> > keep
> > it as it is now and never "fix" it. I'd like the first option :).
> I really hate it. Breaking applications should not even be an option on the
> table. Let's start with "we won't gratuitously break applications" and work
> to find a solution from there.
> > Of course if we can find a better solution to have them both is even
> > better
> > !

What I was trying to say here is that I'd like to have by default C++11 scoped 
enums scoped also on QML, but if everybody thinks is a no go, than we can co 
the other way around.

Anyway, I checked the code a little bit, hopping it will be a few lines 
change, but I was so wrong :). I tried to prefix the (scoped) enum keys with 
the "EnumName." but of course it didn't worked :D, "EnumName_" works fine. It 
seems it needs much love (probably some virtual types based on EnumName), 
unfortunately my QML engine knowledge are too limited to continue :).


More information about the Development mailing list