50 |
50 |
51 qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); |
51 qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); |
52 qmlRegisterType<Person>("People", 1,0, "Person"); |
52 qmlRegisterType<Person>("People", 1,0, "Person"); |
53 |
53 |
54 QDeclarativeEngine engine; |
54 QDeclarativeEngine engine; |
55 QDeclarativeComponent component(&engine, ":example.qml"); |
55 QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); |
56 BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create()); |
56 BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create()); |
57 |
57 |
58 if (party && party->host()) { |
58 if (party && party->host()) { |
59 qWarning() << party->host()->name() << "is having a birthday!"; |
59 qWarning() << party->host()->name() << "is having a birthday!"; |
60 qWarning() << "They are inviting:"; |
60 qWarning() << "They are inviting:"; |
61 for (int ii = 0; ii < party->guestCount(); ++ii) |
61 for (int ii = 0; ii < party->guestCount(); ++ii) |
62 qWarning() << " " << party->guest(ii)->name(); |
62 qWarning() << " " << party->guest(ii)->name(); |
63 } else { |
63 } else { |
64 qWarning() << "An error occured"; |
64 qWarning() << component.errors(); |
65 } |
65 } |
66 |
66 |
67 return 0; |
67 return 0; |
68 } |
68 } |