I'd like to make a slight change to enum property behavior in QML.
Currently you get a compile error if you assign an int to an enum
property, similar to the warning you'll get in C++ if you do the same.
However in C++ you can easily work around this by casting it to the
enum, or just ignoring the warning. Neither option is available in
QML.

Note that since this relaxes the constraints of the language,
previously running QML will continue to run as before.

I'll enumerate the pros and cons:

Pros:
-Matches expectations from C++ users a little better
-Matches expectations from script users a little better
Cons:
-Code is usually less readable when you use ints.
-Less typesafe (although the actual type of enum isn't checked, merely
that it is an enum, so it's not that big a loss).

And a further quirk, you can already get this behavior if you make
your properties int properties instead of enums currently (because
enums can be assigned to int properties). However this is ugly for
classes which are also exposed as C++ APIs, as they'd much prefer to
use enums for a good C++ API.

Since it's a bit of a borderline issue, with minimal gains or losses,
I'd like some further opinions on the issue. Does anyone feel strongly
for or against this change?

--
Alan Alpert
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to