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



  • 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.



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



  • That worked out.

    Thank you very much.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.