Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using signals of a parent class as notifiers for Q_PROPERTY
Forum Updated to NodeBB v4.3 + New Features

Using signals of a parent class as notifiers for Q_PROPERTY

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    YetAnotherNick
    wrote on last edited by
    #1

    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_OBJECT

    public:
    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?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      It compiles and works without problems here (Qt 4.7.0).

      Did you clean your project, re-run qmake and build again?

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        YetAnotherNick
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          YetAnotherNick
          wrote on last edited by
          #4

          Seems like it's not allowed:

          http://bugreports.qt.nokia.com/browse/QTBUG-7684?focusedCommentId=124122&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-124122.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved