--nextPart5717298.E47xrrF2Hp Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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) >> { >> =A0 =A0 void *args[] =3D { &b }; >> =A0 =A0 int id =3D metaObject()->indexOfMethod("privateFunction(bool)"); >> =A0 =A0 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. The above is what the invokeMethod() call does. It hides the gory details=20 from you, but that's all. You should use it because the above actually contains an error. It should=20 have been: void *args[] =3D { 0, &b }; args[0] is used to hold the return value. (Put a variable there and=20 qt_metacall will store the return value for you in it) Note, however, that indexOfMethod takes a *normalised* name. The following= =20 will never work (will return -1): indexOfMethod("privateFunction( bool )"); indexOfMethod("privateFunction(const QString&)"); indexOfMethod("privateFunction(char const *)"); Using invokeMethod hides the normalisation process from you and also=20 provides a modicum of type safety. >[Declaration] > >> protected: >> =A0 =A0 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? That's a binary- and source-compatible change. Unlike the virtual table,=20 the meta object searches entries by string comparison -- the=20 indexOfMethod call above. So you can add and remove as many entries as=20 you want. Also, note that setting the method to Q_SCRIPTABLE or making it a slot=20 makes it invokable too. (Slots can be scriptable too) =2D-=20 =A0 Thiago Macieira =A0- =A0thiago (AT) macieira.info - thiago (AT) kde.org =A0 =A0 PGP/GPG: 0x6EF45358; fingerprint: =A0 =A0 E067 918B B660 DBD1 105C =A0966C 33F5 F005 6EF4 5358 --nextPart5717298.E47xrrF2Hp Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iD8DBQBIfR3mM/XwBW70U1gRAoNEAJ9lF+AlZVl4+IN3YHu50CLeMtxOhACgwz1t FOo8w0wnSo6oZoBLNVOjsjk= =8dci -----END PGP SIGNATURE----- --nextPart5717298.E47xrrF2Hp--