Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Error: Unknown method return type

    QML and Qt Quick
    3
    4
    316
    Loading More Posts
    • 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.
    • DuBu
      DuBu last edited by

      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?

      KroMignon 1 Reply Last reply Reply Quote 0
      • KroMignon
        KroMignon @DuBu last edited by

        @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)

        DuBu 1 Reply Last reply Reply Quote 0
        • DuBu
          DuBu @KroMignon last edited by

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

          1 Reply Last reply Reply Quote 0
          • IntruderExcluder
            IntruderExcluder last edited by

            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 Reply Quote 0
            • First post
              Last post