[Qt-interest] Virtual signals in base class?
Anders Bakken
abakken at netflix.com
Mon Sep 13 21:16:31 CEST 2010
On Thu, Sep 09, 2010 at 12:49:26AM -0700, Robert Caldecott wrote:
> Whilst reviewing some Qt C++ code I came across this:
>
> class Foo
> {
> Q_OBJECT
>
> signals:
> virtual void someSignal(const QString& str, int n)
> {
> Q_UNUSED(str);
> Q_UNUSED(n);
> }
> ...
> };
>
> Now, Qt signals cannot have a body so I'm surprised this even compiles
> (perhaps because the body is effectively empty). I also don't see the
> point of making a signal virtual (as it can't have a body so how can
> it be overridden?)
>
> Am I missing something here or is this code actually valid?
My best guess is that this code is not moc'ed so the generated function
is never compiled (or even generated).
regards
--
Anders Bakken
More information about the Qt-interest-old
mailing list