[Interest] Q_PROPERTY, Subclass and calling SuperClasses signal
André Somers
andre at familiesomers.nl
Fri Feb 28 09:23:51 CET 2014
Jason H schreef op 27-2-2014 17:51:
> 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.
It's clear that this is a limitation of moc, but not something that is
illegal from a design point of view. I think that indeed what Michael is
trying to do is _legal_ in principle, but is prevented in practice by a
_limitation_ of moc. There has been an experiment [1] to use libclang to
re-implement moc. I am wondering if that approach would actually allow
using a signal declared in a base class, as you're using a real compiler
to do the work instead of using glorified text parser.
André
[1] http://woboq.com/blog/moc-with-clang.html
>
> ------------------------------------------------------------------------
> *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
> <mailto: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 <mailto:Interest at qt-project.org>
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140228/f2d041e8/attachment.html>
More information about the Interest
mailing list