QML reports ReferenceError: XYZ is not defined on C++ object added to context
问题 I've started learning QML recently (after trying it out a long time ago) and I'm stuck at the way Qt C++ code interacts with QML and vice versa. I have a Counter which has the following header: #include <QObject> #include <QTimer> class Counter : public QObject { Q_OBJECT Q_PROPERTY(int count READ getCount WRITE setCount NOTIFY signalCountChanged) public: Counter(QObject *parent = Q_NULLPTR); int getCount(); void setCount(int count); signals: void signalCountChanged(int); public slots: void