[Interest] Q_PROPERTY, Subclass and calling SuperClasses signal

Michael Jackson imikejackson at gmail.com
Thu Feb 27 17:31:51 CET 2014




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 {
> Q_OBJECT
> 
> ….
> signals:
>    void parametersChanged();
> ….
> };
> 
> 
> class AlignSectionsFeatureCentroid : public A {
>  Q_OBJECT
> 
> 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:

https://bugreports.qt-project.org/browse/QTBUG-7684?focusedCommentId=124122&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel

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

Does Qt 5.2 have this issue?
--
Mike Jackson




More information about the Interest mailing list