summaryrefslogtreecommitdiffstats
path: root/examples/declarative/extending/properties
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-04-21 00:58:02 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-04-21 00:59:45 (GMT)
commit61f3cb6e79fea0aed80df091013c2228f64955ec (patch)
tree916d4879a326739673f918fc340bc5a4c356bcb9 /examples/declarative/extending/properties
parente11a5c4d1a1bb80ac03655227c833b560c7cad3c (diff)
downloadQt-61f3cb6e79fea0aed80df091013c2228f64955ec.zip
Qt-61f3cb6e79fea0aed80df091013c2228f64955ec.tar.gz
Qt-61f3cb6e79fea0aed80df091013c2228f64955ec.tar.bz2
Improve docs and examples for Extending QML in C++
Diffstat (limited to 'examples/declarative/extending/properties')
-rw-r--r--examples/declarative/extending/properties/birthdayparty.cpp10
-rw-r--r--examples/declarative/extending/properties/birthdayparty.h14
-rw-r--r--examples/declarative/extending/properties/example.qml4
-rw-r--r--examples/declarative/extending/properties/main.cpp4
-rw-r--r--examples/declarative/extending/properties/person.h10
5 files changed, 21 insertions, 21 deletions
diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp
index 14fd6a3..27d17a1 100644
--- a/examples/declarative/extending/properties/birthdayparty.cpp
+++ b/examples/declarative/extending/properties/birthdayparty.cpp
@@ -41,19 +41,19 @@
#include "birthdayparty.h"
BirthdayParty::BirthdayParty(QObject *parent)
-: QObject(parent), m_celebrant(0)
+: QObject(parent), m_host(0)
{
}
// ![0]
-Person *BirthdayParty::celebrant() const
+Person *BirthdayParty::host() const
{
- return m_celebrant;
+ return m_host;
}
-void BirthdayParty::setCelebrant(Person *c)
+void BirthdayParty::setHost(Person *c)
{
- m_celebrant = c;
+ m_host = c;
}
QDeclarativeListProperty<Person> BirthdayParty::guests()
diff --git a/examples/declarative/extending/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h
index dd01562..39ce9ba 100644
--- a/examples/declarative/extending/properties/birthdayparty.h
+++ b/examples/declarative/extending/properties/birthdayparty.h
@@ -42,33 +42,33 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qdeclarative.h>
+#include <QDeclarativeListProperty>
#include "person.h"
// ![0]
class BirthdayParty : public QObject
{
-Q_OBJECT
+ Q_OBJECT
// ![0]
// ![1]
-Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
+ Q_PROPERTY(Person *host READ host WRITE setHost)
// ![1]
// ![2]
-Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
// ![2]
// ![3]
public:
BirthdayParty(QObject *parent = 0);
- Person *celebrant() const;
- void setCelebrant(Person *);
+ Person *host() const;
+ void setHost(Person *);
QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
private:
- Person *m_celebrant;
+ Person *m_host;
QList<Person *> m_guests;
};
// ![3]
diff --git a/examples/declarative/extending/properties/example.qml b/examples/declarative/extending/properties/example.qml
index 9594a84..35abdd6 100644
--- a/examples/declarative/extending/properties/example.qml
+++ b/examples/declarative/extending/properties/example.qml
@@ -2,12 +2,12 @@ import People 1.0
// ![0]
BirthdayParty {
- celebrant: Person {
+ host: Person {
name: "Bob Jones"
shoeSize: 12
}
guests: [
- Person { name: "Joan Hodges" },
+ Person { name: "Leo Hodges" },
Person { name: "Jack Smith" },
Person { name: "Anne Brown" }
]
diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp
index 350f8bd..85e9584 100644
--- a/examples/declarative/extending/properties/main.cpp
+++ b/examples/declarative/extending/properties/main.cpp
@@ -56,8 +56,8 @@ int main(int argc, char ** argv)
QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
- if (party && party->celebrant()) {
- qWarning() << party->celebrant()->name() << "is having a birthday!";
+ if (party && party->host()) {
+ qWarning() << party->host()->name() << "is having a birthday!";
qWarning() << "They are inviting:";
for (int ii = 0; ii < party->guestCount(); ++ii)
qWarning() << " " << party->guest(ii)->name();
diff --git a/examples/declarative/extending/properties/person.h b/examples/declarative/extending/properties/person.h
index 7504d18..0029b09 100644
--- a/examples/declarative/extending/properties/person.h
+++ b/examples/declarative/extending/properties/person.h
@@ -42,12 +42,12 @@
#define PERSON_H
#include <QObject>
-#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);