examples/declarative/cppextensions/referenceexamples/coercion/main.cpp
changeset 37 758a864f9613
parent 30 5dc02b23752f
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    54 // ![0]
    54 // ![0]
    55     qmlRegisterType<Boy>("People", 1,0, "Boy");
    55     qmlRegisterType<Boy>("People", 1,0, "Boy");
    56     qmlRegisterType<Girl>("People", 1,0, "Girl");
    56     qmlRegisterType<Girl>("People", 1,0, "Girl");
    57 
    57 
    58     QDeclarativeEngine engine;
    58     QDeclarativeEngine engine;
    59     QDeclarativeComponent component(&engine, ":example.qml");
    59     QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
    60     BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
    60     BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
    61 
    61 
    62     if (party && party->host()) {
    62     if (party && party->host()) {
    63         qWarning() << party->host()->name() << "is having a birthday!";
    63         qWarning() << party->host()->name() << "is having a birthday!";
    64 
    64 
    68             qWarning() << "She is inviting:";
    68             qWarning() << "She is inviting:";
    69 
    69 
    70         for (int ii = 0; ii < party->guestCount(); ++ii)
    70         for (int ii = 0; ii < party->guestCount(); ++ii)
    71             qWarning() << "   " << party->guest(ii)->name();
    71             qWarning() << "   " << party->guest(ii)->name();
    72     } else {
    72     } else {
    73         qWarning() << "An error occured";
    73         qWarning() << component.errors();
    74     }
    74     }
    75 
    75 
    76     return 0;
    76     return 0;
    77 }
    77 }