enumeration QML Basic Type

a named enumeration value.

The enumeration type refers to a named enumeration value.

Each named value can be referred to as <Type>.<value>. For example, the Text type has an AlignRight enumeration value:

Text { horizontalAlignment: Text.AlignRight }

(For backwards compatibility, the enumeration value may also be specified as a string, e.g. "AlignRight". This form is not recommended for new code.)

When integrating with C++, note that any enum value passed into QML from C++ is automatically converted into an enumeration value, and vice-versa.

This basic type is provided by the QML language. Some enumeration values are provided by the QtQuick import.

Using the enumeration Type in QML

The enumeration type is a representation of a C++ enum type. It is not possible to refer to the enumeration type in QML itself; instead, the int or var types can be used when referring to enumeration values from QML code.

For example:

import QtQuick 2.0

Item {
    // refer to Text.AlignRight using an int type
    property int enumValue: textItem.horizontalAlignment

    signal valueEmitted(int someValue)

    Text {
        id: textItem
        horizontalAlignment: Text.AlignRight

    // emit valueEmitted() signal, which expects an int, with Text.AlignRight
    Component.onCompleted: valueEmitted(Text.AlignRight)

See also QML Basic Types.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support