I declare my object in C ++
class Action : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name) public: Action(): QObject(0) {} QString name() const { return "rem"; } Q_INVOKABLE void getData() {}; }
and make it available to qml:
engine()->rootContext()->setContextProperty("action", new Action());
How to pass getData () javascript method as parameter and call this function on C ++ side?
So, from a QML perspective, it should look like this:
action.getData(function(data) { alert(data); });
source share