diff options
Diffstat (limited to 'examples/declarative/cppextensions')
10 files changed, 60 insertions, 49 deletions
diff --git a/examples/declarative/cppextensions/referenceexamples/adding/person.h b/examples/declarative/cppextensions/referenceexamples/adding/person.h index 896bf4bd52..45fb2f3297 100644 --- a/examples/declarative/cppextensions/referenceexamples/adding/person.h +++ b/examples/declarative/cppextensions/referenceexamples/adding/person.h @@ -41,7 +41,7 @@ #define PERSON_H #include <QObject> -// ![0] +//![0] class Person : public QObject { Q_OBJECT @@ -60,6 +60,6 @@ private: QString m_name; int m_shoeSize; }; -// ![0] +//![0] #endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h index 02e9593b8b..c789c0bd51 100644 --- a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h +++ b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h @@ -75,12 +75,15 @@ public: int guestCount() const; Person *guest(int) const; + //! [static attached] static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + //! [static attached] private: Person *m_host; QList<Person *> m_guests; }; +//! [declare attached] QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - +//! [declare attached] #endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/example.qml b/examples/declarative/cppextensions/referenceexamples/attached/example.qml index c21813ebf9..6a83af2804 100644 --- a/examples/declarative/cppextensions/referenceexamples/attached/example.qml +++ b/examples/declarative/cppextensions/referenceexamples/attached/example.qml @@ -40,32 +40,29 @@ import People 1.0 +//! [begin] BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } +//! [begin] +//! [rsvp] + Boy { + name: "Robert Campbell" + BirthdayParty.rsvp: "2009-07-01" + } +//! [rsvp] // ![1] - Boy { - name: "Leo Hodges" + Boy { + name: "Leo Hodges" shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } BirthdayParty.rsvp: "2009-07-06" } // ![1] - Boy { - name: "Jack Smith" + Boy { + name: "Jack Smith" shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } } - Girl { - name: "Anne Brown" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - - BirthdayParty.rsvp: "2009-07-01" - } +//! [end] } +//! [end] diff --git a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp b/examples/declarative/cppextensions/referenceexamples/attached/main.cpp index 21f076c3b7..4c2c3003fe 100644 --- a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/attached/main.cpp @@ -70,12 +70,13 @@ int main(int argc, char ** argv) for (int ii = 0; ii < party->guestCount(); ++ii) { Person *guest = party->guest(ii); + //! [query rsvp] QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject<BirthdayParty>(guest, false); + QObject *attached = qmlAttachedPropertiesObject<BirthdayParty>(guest, false); + if (attached) rsvpDate = attached->property("rsvp").toDate(); - + //! [query rsvp] if (rsvpDate.isNull()) qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; else diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp index e0eabae4b4..95b309de4c 100644 --- a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp @@ -49,11 +49,14 @@ int main(int argc, char ** argv) QCoreApplication app(argc, argv); qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); -// ![0] + //![0] qmlRegisterType<Person>(); -// ![0] + //![0] + + //![register boy girl] qmlRegisterType<Boy>("People", 1,0, "Boy"); qmlRegisterType<Girl>("People", 1,0, "Girl"); + //![register boy girl] QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/person.h b/examples/declarative/cppextensions/referenceexamples/coercion/person.h index 65faaf1521..dc4ae43dd6 100644 --- a/examples/declarative/cppextensions/referenceexamples/coercion/person.h +++ b/examples/declarative/cppextensions/referenceexamples/coercion/person.h @@ -69,13 +69,14 @@ public: Boy(QObject * parent = 0); }; - +//! [girl class] class Girl : public Person { Q_OBJECT public: Girl(QObject * parent = 0); }; +//! [girl class] // ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/example.qml b/examples/declarative/cppextensions/referenceexamples/grouped/example.qml index 21e368abc4..9ae80f222e 100644 --- a/examples/declarative/cppextensions/referenceexamples/grouped/example.qml +++ b/examples/declarative/cppextensions/referenceexamples/grouped/example.qml @@ -44,30 +44,34 @@ import People 1.0 BirthdayParty { host: Boy { name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + shoe { size: 12; color: "white"; brand: "Bikey"; price: 90.0 } } - Boy { - name: "Leo Hodges" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + Boy { + name: "Leo Hodges" +//![grouped] + shoe { size: 10; color: "black"; brand: "Thebok"; price: 59.95 } +//![grouped] } // ![1] - Boy { - name: "Jack Smith" - shoe { + Boy { + name: "Jack Smith" + shoe { size: 8 color: "blue" - brand: "Puma" - price: 19.95 + brand: "Luma" + price: 19.95 } } // ![1] - Girl { - name: "Anne Brown" + Girl { + name: "Anne Brown" +//![ungrouped] shoe.size: 7 shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 + shoe.brand: "Job Macobs" + shoe.price: 699.99 +//![ungrouped] } } // ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/methods/example.qml b/examples/declarative/cppextensions/referenceexamples/methods/example.qml index adc8cf7590..9119835e04 100644 --- a/examples/declarative/cppextensions/referenceexamples/methods/example.qml +++ b/examples/declarative/cppextensions/referenceexamples/methods/example.qml @@ -41,7 +41,6 @@ import QtQuick 2.0 import People 1.0 -// ![0] BirthdayParty { host: Person { name: "Bob Jones" @@ -53,6 +52,7 @@ BirthdayParty { Person { name: "Anne Brown" } ] +// ![0] Component.onCompleted: invite("William Green") -} // ![0] +} diff --git a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp b/examples/declarative/cppextensions/referenceexamples/properties/main.cpp index d037d88f20..421ce9fbaa 100644 --- a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp +++ b/examples/declarative/cppextensions/referenceexamples/properties/main.cpp @@ -48,8 +48,10 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); +//![register list] qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); qmlRegisterType<Person>("People", 1,0, "Person"); +//![register list] QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); diff --git a/examples/declarative/cppextensions/referenceexamples/signal/example.qml b/examples/declarative/cppextensions/referenceexamples/signal/example.qml index ba792a8617..796c2f32a1 100644 --- a/examples/declarative/cppextensions/referenceexamples/signal/example.qml +++ b/examples/declarative/cppextensions/referenceexamples/signal/example.qml @@ -40,8 +40,8 @@ import People 1.0 -// ![0] BirthdayParty { +// ![0] onPartyStarted: console.log("This party started rockin' at " + time); // ![0] @@ -50,22 +50,22 @@ BirthdayParty { shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } } - Boy { - name: "Leo Hodges" + Boy { + name: "Leo Hodges" BirthdayParty.rsvp: "2009-07-06" shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } } - Boy { - name: "Jack Smith" + Boy { + name: "Jack Smith" shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } } - Girl { - name: "Anne Brown" + Girl { + name: "Anne Brown" BirthdayParty.rsvp: "2009-07-01" shoe.size: 7 shoe.color: "red" shoe.brand: "Marc Jacobs" - shoe.price: 699.99 + shoe.price: 699.99 } // ![1] } |