[Development] QML: Why C++11 scoped enums are not scoped in QML?
dominik.holland at pelagicore.com
Thu Jul 28 09:52:56 CEST 2016
Am 28.07.16 um 09:41 schrieb Olivier Goffart:
> On Donnerstag, 28. Juli 2016 10:32:54 CEST BogDan Vatra wrote:
>> 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
>>>>> 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
>>>> 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
>>> table. Let's start with "we won't gratuitously break applications" and
>>> to find a solution from there.
>>>> Of course if we can find a better solution to have them both is even
>> 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 :).
> Note that in C++11, all enums can be used scoped. (even the normal ones)
> I think it would make sens to allow all enum to be used scoped in QML too.
Mhh how do you make sure that the Enum names are unique ? E.g. having
two custom Items and both having a Enum in them called Type, what whould
you get if you do Type.FOO ?
I think this is dangerous to add as currently the enums are not typesafe
in QML and are basically just ints, last time i checked it was able to
assign an enum value from enumA to and an property holding enumB without
More information about the Development