Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Enum declarations in QML
Qt 6.11 is out! See what's new in the release blog

Enum declarations in QML

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QKelteseth
    wrote on last edited by
    #1

    So with the added support of enum declarations in QML since Qt 5.10 and QtCreator 4.8 I'm still unable to create an enum in qml:

        enum MyState {
            StateOne,
            StateTwo,
            StateThree
        }
    
        property int test: MyState.StateOne
    

    ReferenceError: MyState is not defined

    What am I missing?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      Did you use Q_ENUM to export to QML ?
      e.g Q_ENUM(MyState)

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      Q 1 Reply Last reply
      0
      • dheerendraD dheerendra

        Did you use Q_ENUM to export to QML ?
        e.g Q_ENUM(MyState)

        Q Offline
        Q Offline
        QKelteseth
        wrote on last edited by
        #3

        @dheerendra this is not c++ code. This is purely qml...

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          QKelteseth
          wrote on last edited by
          #4

          Fixed: http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#enumeration-attributes
          Filename.EnumName.EnumValue

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved