examples/declarative/cppextensions/referenceexamples/adding/main.cpp
changeset 37 758a864f9613
parent 30 5dc02b23752f
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    49 //![0]
    49 //![0]
    50     qmlRegisterType<Person>("People", 1,0, "Person");
    50     qmlRegisterType<Person>("People", 1,0, "Person");
    51 //![0]
    51 //![0]
    52 
    52 
    53     QDeclarativeEngine engine;
    53     QDeclarativeEngine engine;
    54     QDeclarativeComponent component(&engine, ":example.qml");
    54     QDeclarativeComponent component(&engine, QUrl("qrc:example.qml"));
    55     Person *person = qobject_cast<Person *>(component.create());
    55     Person *person = qobject_cast<Person *>(component.create());
    56     if (person) {
    56     if (person) {
    57         qWarning() << "The person's name is" << person->name();
    57         qWarning() << "The person's name is" << person->name();
    58         qWarning() << "They wear a" << person->shoeSize() << "sized shoe";
    58         qWarning() << "They wear a" << person->shoeSize() << "sized shoe";
    59     } else {
    59     } else {
    60         qWarning() << "An error occured";
    60         qWarning() << component.errors();
    61     }
    61     }
    62 
    62 
    63     return 0;
    63     return 0;
    64 }
    64 }