[Development] [QML] Assigning ints to enumeration properties

Laszlo Papp lpapp at kde.org
Wed Mar 6 05:51:47 CET 2013

On Wed, Mar 6, 2013 at 12:17 AM, Alan Alpert <416365416c at gmail.com> wrote:

> >> -Matches expectations from C++ users a little better
> >
> >
> > What do you mean by this? I personally prefer that the enum is getting
> > strongly typed with C++11.On the conrary, I have always used int enums in
> > QML applications.
> While I haven't checked C++11, with C++98 (default compiler flags) the
> following line compiles:

OK, never mind, this was just a bit of sidetrack from me to demonstrate I
like as much type safety as possible.

> m_enumMember = 1;
You might get a warning, but you also get a working application.

You might get a working application. I would not call that an expectation
from C++ users though (i.e. I would prefer explicit casting to make it
clear). I would personally avoid such scenarios when possible as a C++
user. Note, I am writing this regardless of the relaxing for QML. This
sentence just made me wonder.

Overall, I agree about this relaxing as I also used integers for enums, and
I think this is necessary at times. This is probably not as bad as in C++
due to the language differences.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130306/21598cd9/attachment.html>

More information about the Development mailing list