[Development] Enumerations in QML

Tony Van Eerd tvaneerd at rim.com
Thu Dec 13 23:09:57 CET 2012


> -----Original Message-----
> 
> I don't think it adds the real value, which comes from just matching
> C++ expectations. Enums help out in C++ because they're A)
> high-performance B) high-readability and C) Object-Oriented. By
> putting enums in their own files as their own types we lose most of C
> (and some of A) because they're no longer attached to the object they
> are conceptually associated with. The C++ enum State { On, Off,
> Automatic } isn't very great or clear if it's in the global namespace,
> but could make sense if it's attached to a class (e.g.
> MotorControl::State). You also lose the compatibility of matching C++
> syntax: A C++ type has all its enums on the type name (e.g.
> Text.AlignVertical) wheras here each QML enum has its own type (e.g.
> Align.vertical) which is not the same syntax.
> 

Don't forget that C++'s syntax for enums is (finally!) changing:

//C++98
enum State { On, Off, Automatic };
State state = On;

//C++11
enum class State { On, Off, Automatic };
State state = State::On;


Tony

---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.



More information about the Development mailing list