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. Error: Unknown method return type
Forum Updated to NodeBB v4.3 + New Features

Error: Unknown method return type

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 1.1k Views 1 Watching
  • 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.
  • DuBuD Offline
    DuBuD Offline
    DuBu
    wrote on last edited by
    #1

    Hi,

    I have a custom type declared in C++:

    class MyType : public QObject {
      Q_OBJECT
      ...
    };
    

    In main.cpp I registered that Type:

    qmlRegisterType<MyType>("MyType", 1, 0, "MyType");
    

    Somewhere else I've got a function returning a pointer to that type:

    Q_INVOKABLE MyType* getMyType() const { ... }
    

    So far, so good. But when I call the function getMyType() from QML, I get the following error:

    Error: Unknown method return type: MyType*
    

    What am I missing?

    KroMignonK 1 Reply Last reply
    0
    • DuBuD DuBu

      Hi,

      I have a custom type declared in C++:

      class MyType : public QObject {
        Q_OBJECT
        ...
      };
      

      In main.cpp I registered that Type:

      qmlRegisterType<MyType>("MyType", 1, 0, "MyType");
      

      Somewhere else I've got a function returning a pointer to that type:

      Q_INVOKABLE MyType* getMyType() const { ... }
      

      So far, so good. But when I call the function getMyType() from QML, I get the following error:

      Error: Unknown method return type: MyType*
      

      What am I missing?

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #2

      @DuBu said in Error: Unknown method return type:

      What am I missing?

      maybe import MyType 1.0 in you qml?

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      DuBuD 1 Reply Last reply
      0
      • KroMignonK KroMignon

        @DuBu said in Error: Unknown method return type:

        What am I missing?

        maybe import MyType 1.0 in you qml?

        DuBuD Offline
        DuBuD Offline
        DuBu
        wrote on last edited by
        #3

        @KroMignon No, I forgot to mention, MyType was already imported.

        1 Reply Last reply
        0
        • IntruderExcluderI Offline
          IntruderExcluderI Offline
          IntruderExcluder
          wrote on last edited by
          #4

          MyType* and MyType are different types and must be registered separately. Also it may be better/easier just to return QObject* instead of MyType*, properties/stots will be visible in QML.

          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