I see the problem. Thank you for pointing that out! Since then I have been thinking about how to solve this, but having been been fine with staying on Qt 5.5 for the time being I've had no pressure to - but with Qt5.7 there are some gui-features which I want use, so I really have to solve my dilemma. I have to set List properties of different objects, all derived from "Entity". Because of abstracted methods, in my context I can only see QList<QSharedPointer<Entity>> and not QList<QSharedPointer<Person>> (Where Person derives from Entity) <code> void Class::setListProperty(const QSharedPointer<Entity> &entity, QList<QSharedPointer<Entity>> &list, const QMetaProperty &property) { QVariant var; var.setValue<QList<QSharedPointer<Entity>>>(list); QVERIFY(property.write(entity.data(), var)); } </code> With an EntityInstanceFactory it's possible to instantiate an object of the actual class (e.g. Person) and I can see its classname ("Person") as a string, too - But the interface type is, of course, still: QList<QSharedPointer<Entity>> - and that is not enough, because for the use of QMetaProperty::write I do understand that I need <QList<QSharedPointer<Person>>. I'd happily use templates, but at compile time there is no way to know what the specific class will be, as data is being retrieved at runtime from a data base. Any idea how I can get an instance of QList<QSharedPointer<Person>> in this context? Am Freitag, den 06.05.2016, 22:26 -0700 schrieb Thiago Macieira: > On sábado, 7 de maio de 2016 01:36:42 PDT Christian Ehringfeld wrote: > > Yes, you can find it here: > > https://github.com/Professi/metaproperty-write-test > > Test fails under Qt 5.6 and is succesful under Qt 5.5.1. > > > > When I remove the inheritance between person and entity it also works > > with Qt 5.6. > > > You're trying to set a property of type QList<QSharedPointer<Person>> with a > > variant containing QList<QSharedPointer<Entity>>. That's not supposed to work > because lists in C++ do not support covariance nor contravariance. >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest