Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

QQmlListProperty: QObject subclass usage

$
0
0
I have a QObject subclass like in this [qt-project.org] example, and I have a list property in it: class Subclass: public QObject {     Q_OBJECT     Q_PROPERTY(QQmlListProperty<Subclass> content READ content)     QList<Subclass*> mContent; public:     QQmlListProperty<Subclass> content() {return QQmlListProperty<Subclass>(this, mContent);} } I don’t see any difference, however if I try to set it from QML, I get “Cannot assign multiple values to a singular property”. BUT! With the following code everything works: class Subclass: public QObject {     Q_OBJECT     Q_PROPERTY(QQmlListProperty<QObject> content READ content)     QList<QObject*> mContent; public:     QQmlListProperty<QObject> content() {return QQmlListProperty<QObject>(this, mContent);} } Can you tell me what is wrong? I do want QQmlListProperty<Subclass> to have an automatic typecheck, because I need that only Subclass and it’s children to be set as “content”.

Viewing all articles
Browse latest Browse all 4972

Trending Articles