[Interest] Can slot be virtual?

Igor Mironchik igor.mironchik at gmail.com
Mon Dec 29 09:58:42 CET 2014


Thanks for yor answer, André.

On Mon, 29 Dec 2014 10:27:55 +0300, André Somers <andre at familiesomers.nl>  
wrote:

> Igor Mironchik schreef op 29-12-2014 om 06:51:
>> Slots in Qt can be virtual. But may be there some underwater stones?
>>
>> What do you know/think?
>>
> No, this works just fine and can be very useful.
> You should, however, not mark the function as a slot more than once.
> Mark it as a slot in your base class, then simply override in your
> subclasses without adding the slot marker for moc.
>
> One consideration may be API design though. I generally try to keep my
> API for _using_ a class separate from the one for _extending_ it. SLOTS
> are often (though not always) in the public API surface. Are you sure
> that that is also the surface you want to extend? You may consider to
> instead have a non-virtual public slot start(), than in turn calls a
> virtual private or protected method run(). The start method is then part
> of your _use_ API surface, while the _run_ method is part of the
> _extention_ API.
>
> André
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest


-- 
Best Regards,
Igor Mironchik.



More information about the Interest mailing list