error: variable 'QQmlComponent component' has initializer but incomplete type in Qt5

后端 未结 2 603
说谎
说谎 2021-01-27 13:18

i am playing with Exposing Attributes of C++ Types to QML in Qt5 based on this tutor http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-exposecppattributes.html. when i

2条回答
  •  暖寄归人
    2021-01-27 14:01

    I believe you need to add:

    signals: 
      void authorChanged();
    

    to your class like this:

      class Message : public QObject
    {
    Q_OBJECT
    Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged)
    public:
        void setAuthor(const QString &a) {
            if (a != m_author) {
                m_author = a;
                emit authorChanged();
            }
        }
        QString author() const {
            return m_author;
        }
    signals:
      void authorChanged();
    private:
        QString m_author;
    };
    

提交回复
热议问题