[Interest] Qt signals and polymorphism

André Somers andre at familiesomers.nl
Mon Nov 23 09:05:31 CET 2015



Op 22/11/2015 om 20:51 schreef Bob Hood:
>
> Ah, I see!  There was the "obvious" thing I was missing. For some 
> unknown reason, I assumed that signals were not inherited.  I just 
> tested without overriding the signal and polymorphism worked as expected.
To to clear that up: there is nothing special about signals. It's all 
just plain C++ after all. A signal is a (public*) method who's 
implementation is provided by moc for you. The 'emit' keyword does 
nothing, it is syntactic sugar. Leave it out and everything still works 
as expected (but I would not recommend doing this in real code.)

As you know, public methods are available for calling from all 
subclasses as well.

André

*) In Qt 5. In Qt 4 it used to be protected. Nothing changes for the 
purpose of this message there.



More information about the Interest mailing list