[Interest] Q_PROPERTY, Subclass and calling SuperClasses signal

Jason H scorp1us at yahoo.com
Thu Feb 27 17:51:52 CET 2014

Moc may be confused by a few things.

1. Q_PROPERTIES normally sppear at the top 
2. your notifier is not in the class you are declaring it as. Either declare it in A, or override it yourself.

Moc is almost magical, but it doesn't have run or compile-time introspection. It can only parse the text you (qt) feeds it. Then it enables introspection of the class based on the supplied text. 

Try the 2 suggestions above.

 From: Michael Jackson <imikejackson at gmail.com>
To: "<interest at qt-project.org>" <interest at qt-project.org> 
Sent: Thursday, February 27, 2014 11:31 AM
Subject: Re: [Interest] Q_PROPERTY, Subclass and calling SuperClasses signal

On Feb 27, 2014, at 11:24 AM, Michael Jackson <imikejackson at gmail.com> wrote:

> I am trying to make sure I truly understand the Signals/Slots mechanism because this once has me a bit stumped. I _think_ what I am trying is legal but maybe not. Best is an example:
> class A : public QObject {
> ….
> signals:
>    void parametersChanged();
> ….
> };
> class AlignSectionsFeatureCentroid : public A {
> public:
>   void set ReferenceSlice(int value) { emit parametersChanged(); }
>   int get ReferenceSlice();
>   Q_PROPERTY(int ReferenceSlice READ get ReferenceSlice WRITE set ReferenceSlice NOTIFY parametersChanged)
> ….
> };
> when I compile this I get a compile error similar to this (error taken straight from my project)
> SectionsFeatureCentroid.h:118: Error: NOTIFY signal 'parametersChanged' of property 'ReferenceSlice' does not exist in class AlignSectionsFeatureCentroid.
> AUTOMOC: error: process for moc_AlignSectionsFeatureCentroid.cpp failed:
> AlignSectionsFeatureCentroid.h:118: Error: NOTIFY signal 'parametersChanged' of property 'ReferenceSlice' does not exist in class AlignSectionsFeatureCentroid.
> But if I define the signals in the subclass then at runtime I get a warning about the subclass over riding the superclass's signals.
> What is the correct answer here?
> Thanks
> Mike Jackson
> dream3d.bluequartz.net

Post too fast. This at least verified what I am trying is legal:


So it seems that moc can not support something that is perfectly legal to do?

Does Qt 5.2 have this issue?

Mike Jackson

Interest mailing list
Interest at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140227/04f16ec6/attachment.html>

More information about the Interest mailing list