[Qt-interest] why signals are not objects?
Volker Hilsheimer
unwatched at gmx.net
Mon May 4 15:11:04 CEST 2009
"Luca Ferrari" <fluca1978 at infinito.it> wrote in message
news:200905041111.30614.fluca1978 at infinito.it...
> Ok, maybe a trivial question, but I didn't find anything about in the
> archives: why signals are not implemented as c++ objects? Should not be
> simpler the implementation of the signal/slot mechanism? I agree that
> the moc
> provides more expressiveness but objects have a simpler implementation.
> So, what is the reason for choosing the moc instead of a set of classes?
>
> Luca
With the current solution you can introspect the signals provided by a
class without having an instance of that class (you only need the static
QMetaObject), and instances of that class carry no additional cost for the
signals declared (connections of course cost dynamic memory anyway).
Implementing signals as member objects adds cost to class instances, which
is not acceptable. Of course you can make the signal objects static class
members, but then you don't have much left in terms of simplicity or
convenience, given that moc is required for other things anyway.
Volker
More information about the Qt-interest-old
mailing list