I'm having a base class I derive from. That base class (BaseClass
) is a pure c++ class (doesn't derive from QObject) and implements methods, which I'd like to provide to my QML interface without alteration.
Let's assume the base class implements a method bool foobar()
. In my derived class (DerivedClass
) I now wrap them like this:
DerivedClass.h:
class DerivedClass : public QObject, public Singleton<Phone>, public BaseClass {
Q_OBJECT
public:
Q_INVOKABLE bool qt_foobar();
DerivedClass.cpp:
bool DerivedClass::qt_foobar() {
return DerivedClass::instance().foobar();
That works perfectly fine, however I'm wondering whether there's a more elegant way to just pass or declare respective methods as Q_INVOKABLE
without that wrapping and renaming.