summaryrefslogtreecommitdiffstats
path: root/examples/declarative/extending/signal/main.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-07 08:17:33 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-07 09:10:35 (GMT)
commit6c901f67fb2f2e73fa362e72d985a04fa57cdf48 (patch)
tree583aab2bd1a6ccac33d310df3e8149da0aece0d5 /examples/declarative/extending/signal/main.cpp
parent131541866b374b90e04af75ec1382154c78b69b9 (diff)
downloadQt-6c901f67fb2f2e73fa362e72d985a04fa57cdf48.zip
Qt-6c901f67fb2f2e73fa362e72d985a04fa57cdf48.tar.gz
Qt-6c901f67fb2f2e73fa362e72d985a04fa57cdf48.tar.bz2
Doc
Diffstat (limited to 'examples/declarative/extending/signal/main.cpp')
-rw-r--r--examples/declarative/extending/signal/main.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp
new file mode 100644
index 0000000..181614d
--- /dev/null
+++ b/examples/declarative/extending/signal/main.cpp
@@ -0,0 +1,45 @@
+#include <QCoreApplication>
+#include <QmlEngine>
+#include <QmlComponent>
+#include <QDebug>
+#include "birthdayparty.h"
+#include "person.h"
+
+int main(int argc, char ** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, ":example.qml");
+ BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
+
+ if (party && party->celebrant()) {
+ qWarning() << party->celebrant()->name() << "is having a birthday!";
+
+ if (qobject_cast<Boy *>(party->celebrant()))
+ qWarning() << "He is inviting:";
+ else
+ qWarning() << "She is inviting:";
+
+ for (int ii = 0; ii < party->guests()->count(); ++ii) {
+ Person *guest = party->guests()->at(ii);
+
+ QDate rsvpDate;
+ QObject *attached =
+ qmlAttachedPropertiesObject<BirthdayParty>(guest, false);
+ if (attached)
+ rsvpDate = attached->property("rsvp").toDate();
+
+ if (rsvpDate.isNull())
+ qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd";
+ else
+ qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString());
+ }
+
+ party->startParty();
+ } else {
+ qWarning() << "An error occured";
+ }
+
+ return 0;
+}