signals and slots vs. virtual_hook (was [PATCH] KFileDialog overwrite confirmation)
Matthias Kretz
kretz at kde.org
Tue Jul 15 18:02:28 BST 2008
On Tuesday 15 July 2008 18:42:05 Leo Savernik wrote:
> Am Dienstag, 15. Juli 2008 schrieb Thiago Macieira:
> > Besides, my point is exactly that qt_metacall *is* the same as
> > virtual_hook. There's no need to involve signals here. Technically all
> > you needed to do was:
> >
> > void MiddleClass::publicFunction(bool b)
> > {
> > void *args[] = { &b };
> > int id = metaObject()->indexOfMethod("privateFunction(bool)");
> > qt_metacall(QMetaObject::InvokeMetaMethod, id, args);
> > }
>
> Cool, I didn't know that! It's ugly, but it should still be faster than a
> slot invocation.
If you cache the index. Otherwise it's pretty much the same AFAIK.
> [Declaration]
>
> > protected:
> > Q_INVOKABLE void privateFunction(bool b);
> > };
>
> Say, I don't have a Q_INVOKABLE in release x. Is then adding Q_INVOKABLE in
> release x+1 BIC?
Yes, it doesn't change anything in the binary representation of the class. It
just tells moc that it should treat this function much like a slot - therefore
the qt_metacall will then work on it.
--
________________________________________________________
Matthias Kretz (Germany) <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
More information about the kde-core-devel
mailing list