Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 660
Registered: ‎10-08-2009
My Device: Bold 9900
My Carrier: Telus

Q_PROPERTY QList

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:

 

app.values[#]

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?

 

 

 

 

----------------------------------------------------------
Twitter: @gyubok
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Q_PROPERTY QList

[ Edited ]

Hi,

It's better to use QDeclarativePropertyList to export lists to QML. QList will leak memory. This page has more information:

http://qt-project.org/wiki/How_to_expose_lists_to_QML

But this won't solve the problem with binding... Smiley Sad

 

UPD: please disregard this post, the wiki page was misleading. I think QDeclarativePropertyList is needed only when lists are populated from QML side.


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 660
Registered: ‎10-08-2009
My Device: Bold 9900
My Carrier: Telus

Re: Q_PROPERTY QList

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?

----------------------------------------------------------
Twitter: @gyubok
Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Q_PROPERTY QList

i usually don't expose the list but size() and at().
QDeclarativePropertyList did not work sometimes.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter