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. QML does not recognize ENUM returned by C++ Q_INVOKABLE function
Forum Updated to NodeBB v4.3 + New Features

QML does not recognize ENUM returned by C++ Q_INVOKABLE function

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

    QML

    console.log("model's category is " + converter.getModelCategory(currentIndex))
    

    C++

    Q_INVOKABLE Unit::Category getModelCategory(int index) { //TODO put in separate file
        qDebug() << "getModelCategory is called, Index is " << index;
        return qobject_cast<Unit *>(CategoryDataModel.at(index))->category();
    }
    

    error
    : Error: Unknown method return type: Unit::Category where Unit::Category is C++ enums and it is declared with Q_ENUM. However, Unit::Category is declared in other QOBJECT derived class, might it be a problem?
    How to solve this issue?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      luosen
      wrote on last edited by
      #2

      As far as I know, "Unit" type need to register throgh qmlRegisterType to make "Unit::Category" visible in QML.

      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