[Development] invokeMethod() with function pointers
b.terrier at gmail.com
Mon Jan 16 19:23:07 CET 2017
2017-01-16 10:34 GMT+01:00 Olivier Goffart <olivier at woboq.com>:
> On Samstag, 14. Januar 2017 17:28:01 CET Benjamin TERRIER wrote:
> > Hi everyone,
> > I'm trying to contribute by making QMetaObject::invokeMethod() take
> > pointers instead of function names.
> > I've come up with something that works by looking at the code of
> > QMetaObject::invokeMethod, QObject::connect and QMetaObject::activate.
> Thanks for your contribution.
> What's the use case for this function? For direct call you better of
> the function directly, and the equivalent of QueuedConnection can be
> with QTimer::singleShot.
> Nevertheless, i guess it's worth adding for the sake of consistency.
Talking for me here, I use QMetaObject::invokeMethod() to call slots of
QObject accross threads.
I could make use of the new form to call any function (not only slots) and
to have some checks during compilation.
The QTimer solution could work, but you cannot add parameters without using
However, I don't really like QGenericArgument which forces to use Q_ARG.
> was just a workaround back in the Qt 4 days, around the lack of template
> member function and variadic template. Since we know the arguments of the
> at compile time, it would be much nicer to pass the arguments directly.
Agreed. I've got something working with variadic templates, I'll update the
But for consistency, it should stay in QMetaObject, I'd say. We might need
> move a few more things to qobjectdefs_impl.h to make it happen.
Can this be done in the same commit? Or do I need to make 2 changes?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Development