Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] Unable to call a Q_INVOKABLE method upon multilevel inheritence
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Unable to call a Q_INVOKABLE method upon multilevel inheritence

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 2.3k 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.
  • S Offline
    S Offline
    Sree
    wrote on last edited by
    #1

    Hi,

    I am having a BaseClass which inherits QObject. Now, this BaseClass is inherited by all of my class files in the application.

    BaseClass.h will look like.
    @class BaseClass: public QObject{
    Q_OBJECT
    public:
    BaseClass();
    BaseClass(AbstractPane *pane);
    }@

    Inherited class header file looks like

    @class ApplicationUI : public BaseClass
    {
    public:
    ApplicationUI(bb::cascades::Application *app);
    virtual ~ApplicationUI() {}

    Q_INVOKABLE void screenTriggered();
    AbstractPane *root;
    

    };@

    I'm binding a QML file for ApplicationUI class which has a Menu option and will call screenTriggered() method upon menu click.

    The issue is the screenTriggered() method is not working in my case. A log saying "TypeError: Result of expression 'cppObj.screenTriggered' [undefined] is not a function." is displayed in Terminal.

    Without Baseclass implementation, inheriting the QObject directly to ApplicationUI class is working perfectly.

    Please help me out.

    Thanks,
    Sha.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Hi!
      You should add
      @Q_OBJECT@
      to every clas which inherits QObject.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sree
        wrote on last edited by
        #3

        That worked out.

        Thank you very much.

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

          You're welcome.
          Will be great if you mark this thread as solved. Just edit first topic and add [Solved] to caption.

          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