Solved How to get QMetaMethod from Object::method?
-
Given I have a QObject inheriting object called
Foo
with a method on it calledbar
, what's the easiest way to get a QMetaMethod object that represents Foo::bar? I'm doing this to create a property-like object that need to encapsulate a getter, setter and notify signal present on Foo. -
@kitfox said in How to get QMetaMethod from Object::method?:
Given I have a QObject inheriting object called Foo with a method on it called bar, what's the easiest way to get a QMetaMethod object that represents Foo::bar?
From the docs:
int functionIndex = qobj.metaObject()->indexOfMethod("testFunc()"); QMetaMethod mm = qobj.metaObject()->method(functionIndex);
https://doc.qt.io/qt-5/qmetamethod.html
https://doc.qt.io/qt-5/qmetaobject.html#indexOfMethod
https://doc.qt.io/qt-5/qmetaobject.html#normalizedSignature