[Interest] Q_PROPERTY, Subclass and calling SuperClasses signal

Michael Jackson imikejackson at gmail.com
Thu Feb 27 18:35:18 CET 2014


it is declared in A? The signal is declared in A. Signals are protected from my understanding so the "signal" should be available in subclasses. But because moc probably does not understand inheritance it gets confused. I'll redesign the classes I guess.

Thanks
Mike J.

On Feb 27, 2014, at 11:51 AM, Jason H <scorp1us at yahoo.com> wrote:

> 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 {
> > 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
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> 
> 




More information about the Interest mailing list