Proposing the removal of virtual_hooks (or how you can add a virtual method without using "virtual")

Frans Englich frans.englich at telia.com
Sun Mar 5 16:55:54 GMT 2006


On Saturday 04 March 2006 11:18, Thiago Macieira wrote:
> I'd like to propose a change of policy in the KDE libraries: remove all
> virtual_hook functions from QObject-derived classes.
>
> The reason for that is that we *already* have a virtual_hook function in
> those classes and it's called qt_metacall. It's automatically generated
> by moc, so we're safe that it'll always exist.

Another way to preserve BC is to use the visitor/double dispatch pattern. It 
can be argued to be a bit heavy code-wise, but achieves the goal and can also 
be fast, depending on various factors. Major pros/cons:

+ Doesn't require QObject
- Requires one virtual function to be added.


Cheers,

		Frans




More information about the kde-core-devel mailing list