Using signals of a parent class as notifiers for Q_PROPERTY
-
If I add a NOTIFY signal in a Q_PROPERTY everything is fine as long as the signal is defined in the same class. However, if I try to use a signal from a parent class, I get a compile error:
@Error: NOTIFY signal 'changed' of property 'name' does not exist in class Foo.@
Sample code:
@class FooBase : public QObject
{
Q_OBJECTpublic:
FooBase(QObject *parent = 0) : QObject(parent) {}signals:
void changed();
};class Foo : public FooBase
{
Q_OBJECT
Q_PROPERTY(QString name READ name NOTIFY changed)public:
Foo(QObject *parent = 0) : FooBase(parent) {}
QString name() const
{
return _name;
}private:
QString _name;
};@Am I doing something wrong? Is this a bug? AFAIK, signals should not be redefined in subclasses, so I shouldn't redefine it but I also can't use the inherited signal, so what can I do? Is creating a nameChanged() signal and connecting it to changed() the only way to go?
-
This same code I posted is just a minimal example to reproduce the problem (that of course also happens in my real project), so yes, it's a clean build. I'm using Qt 4.7.1 BTW.
-