04-10-2013 06:20 PM
Hi, in hpp file in my app, an object is defined as
Q_PROPERTY(QList<int> values READ values)
and I read those values in my qml and display it in label like this:
and it works fine. However, I am trying to change one value from that values object and is currently doing like so:
Q_INVOKABLE QList<int> changeValue(const int index);
but of course, this changing value this way will change the value in the QList values object but does not update in the label in qml, so I am manually updating the text displayed in the label.
The "WRITE newValues" will only accept QList but I would like to know a way to update only one value at specified index from qml and have the change reflected in the label without the extra function call. How can this be achieved?
04-10-2013 06:29 PM - edited 04-11-2013 07:28 AM
It's better to use QDeclarativePropertyList to export lists to QML. QList will leak memory. This page has more information:
But this won't solve the problem with binding...
UPD: please disregard this post, the wiki page was misleading. I think QDeclarativePropertyList is needed only when lists are populated from QML side.
04-10-2013 06:48 PM
Maybe I am not digging deep enough but QDeclaritiveListProperty look quite limited and requires you to create custom functions to make it work like QList. How much memory does QList waste? Given the list is only 16 lengths long with only storing integers, is it that wasteful?
04-11-2013 03:06 AM