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. Access enums defined in non-Qt C++ class.
Forum Updated to NodeBB v4.3 + New Features

Access enums defined in non-Qt C++ class.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 246 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.
  • S Offline
    S Offline
    Sairam_0696
    wrote on last edited by
    #1

    I have a plain C++ defined with enums like

    class MyEnums
    {
    enum someEnum
    {
    VAL1,
    VAL2,
    ....
    }
    };

    I want to use this enum in my QML. Any thoughts how to acheive this?

    Note: This is not a class having Q_OBJECT, Q_NAMESPACE or Q_GADGET and not inherited from QObject.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bob64
      wrote on last edited by
      #2

      You need to use Qt facilities to expose them to QML, the same as if you wanted to call a C++ function from QML. If you are unable to modify the existing C++ code, I would suggest introducing a new Qt-based enum type that mirrors your existing type, expose that to QML, and convert between the two types somewhere appropriate in your backend code.

      1 Reply Last reply
      1

      • Login

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