# qmlRegisterType<Person>("People", 1,0, "Person"); qmlRegisterType(Person, 'People', 1, 0, 'Person'); # QDeclarativeEngine engine; engine = QDeclarativeEngine() # QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); component = QDeclarativeComponent(engine, QUrl("example.qml")) # Person *person = qobject_cast<Person *>(component.create()); person = component.create() # if (person) { if person: # qWarning() << "The person's name is" << person->name(); # qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; qWarning("The person's name is {p.name}".format(p=person)) qWarning("They wear a {p.shoeSize} sized shoe".format(p=person)) # } else { else: # usual approach failed here: needed extract all the errors from a # list, and then cast them to strings. # trying to cast to unicode resulted in an incomplete error message for x in component.errors(): qWarning(str(x)) # qWarning() << component.errors(); # qWarning(component.errors()) # return 0; # nothing equivalent here