diff options
Diffstat (limited to 'examples/declarative/extending/adding')
-rw-r--r-- | examples/declarative/extending/adding/example.qml | 2 | ||||
-rw-r--r-- | examples/declarative/extending/adding/main.cpp | 3 | ||||
-rw-r--r-- | examples/declarative/extending/adding/person.h | 12 |
3 files changed, 9 insertions, 8 deletions
diff --git a/examples/declarative/extending/adding/example.qml b/examples/declarative/extending/adding/example.qml index c608f94..dc891e7 100644 --- a/examples/declarative/extending/adding/example.qml +++ b/examples/declarative/extending/adding/example.qml @@ -1,6 +1,6 @@ +// ![0] import People 1.0 -// ![0] Person { name: "Bob Jones" shoeSize: 12 diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp index b9e5aa3..7b33895 100644 --- a/examples/declarative/extending/adding/main.cpp +++ b/examples/declarative/extending/adding/main.cpp @@ -47,8 +47,9 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - +//![0] qmlRegisterType<Person>("People", 1,0, "Person"); +//![0] QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/adding/person.h b/examples/declarative/extending/adding/person.h index 7a9e0f0..d6de9a9 100644 --- a/examples/declarative/extending/adding/person.h +++ b/examples/declarative/extending/adding/person.h @@ -43,12 +43,11 @@ #include <QObject> // ![0] -#include <qdeclarative.h> - -class Person : public QObject { -Q_OBJECT -Q_PROPERTY(QString name READ name WRITE setName) -Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) public: Person(QObject *parent = 0); @@ -57,6 +56,7 @@ public: int shoeSize() const; void setShoeSize(int); + private: QString m_name; int m_shoeSize; |