Calling static function through QMetaObject
-
wrote on 22 Feb 2016, 12:58 last edited by
Is there a way to invoke a static method of a class without supplying an object to the invokeMethod(...) of the QMetaObject?
-
Why do you want to use invokeMethod() to call a static method?
-
wrote on 22 Feb 2016, 18:40 last edited by
@jsulm Well, because the method that I would like to invoke would not require an instance and therefore a static method is what I prefer. Is there any way to invoke a static method without an instance?
The QMetaObkect::method(index) function also returns me the invokable static methods.
-
hi
Are we talking normal static functions?
http://www.tutorialspoint.com/cplusplus/cpp_static_members.htmso you just call it like
ClassName::static_method()
? -
hi
Are we talking normal static functions?
http://www.tutorialspoint.com/cplusplus/cpp_static_members.htmso you just call it like
ClassName::static_method()
? -
@mrjj Yes, a standard C++ static member function which is defined with Q_INVOKABLE. I will not only know at runtime which staticMetaObject I have to call this function. Therefore I can not use ClassName::static_method().
@walteste
Ok, so this is also regarding calling / make available to QML ? / scripting ? -
This is not possible with current API. Take a look at the generated
moc_*.cpp
file. The methods called via meta objects are always routed throughYourClass::qt_static_metacall
and it always takes an object pointer. -
This is not possible with current API. Take a look at the generated
moc_*.cpp
file. The methods called via meta objects are always routed throughYourClass::qt_static_metacall
and it always takes an object pointer.wrote on 23 Feb 2016, 05:08 last edited by@Chris-Kawa Thanks for the information provided. Then I need to re-design my implementation accordingly to this limitation.
3/9