Set ListElement role from c++
-
Hello!
Is it possible to set in the ListElement role from the c++ context property?
In the way like below I have TypeError:
qml part:ListModel { id: pictureModel ListElement { title: "name" src: "someqml.qml" something: devicemodel.value }main.cpp
DeviceData devicemodel; engine.rootContext()->setContextProperty(QStringLiteral("devicemodel"), &devicemodel);c++ Val class:
class Val: public QObject{ Q_OBJECT Q_PROPERTY(unsigned int curValue READ curValue WRITE writeCurValue NOTIFY curValueChanged) Q_PROPERTY(unsigned int maxValue READ maxValue) Q_PROPERTY(unsigned int minValue READ minValue) }Devicedata class
class DeviceData : public QObject { Q_OBJECT Q_PROPERTY(Val* value READ value NOTIFY valueChanged) } -
Values for roles at
ListElementmust be a simple constants: strings, numbers and boolean values. In your examplevalueproperty is pointer.