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: 1,178
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

RESET clause of Q_PROPERTY()

QML properties are defined for C++ classes with the Q_PROPERTY() macro, which has a RESET clause. I have no problem defining the reset function, but I can't find any documentation on how to trigger the reset function from QML. Does this function get automatically triggered when you set the property to JavaScript null?

 

As an example from Cascades, Container has the layout property, which has a reset function defined for the property. What would be the QML/JavaScript syntax for triggering this?

 

Interestingly, I notice that reset functions are typically dfefined as slots, but not Q_INVOKABLE, so I'm wondering if the property system triggers the slot automatically whenever the property is set to null?



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: RESET clause of Q_PROPERTY()

[ Edited ]

No and you are probably misunderstanding what this function was/is for (I know I did when I first saw it and thought why would I use that). It's for resetting the value to its original context specific value, one that can't be handled by the Write function.

 

Take a look here for more info if you are interested...

 

 

 http://qt-project.org/doc/qt-5.0/qtcore/properties.html


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 1,178
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: RESET clause of Q_PROPERTY()

Actually, I understand exactly what it does, what I can't figure out is when it gets executed. How do you do the reset from QML?

 

For instance, a Container has a layout property, which has a default value, so there is a reset function for layout (resetLayout), but is is not declared as Q_INVOKABLE, so you can't call it from QML. It is however delared as a slot, which suggest to me that when you use the RESET clause with Q_PROPERTY it tells the property system to connect something to the reset function slot to be executed when it wants to reset the layout to default. What I don't get is when this would be triggered. From QML how would you tell the Container to reset its layout?

 


BBSJdev wrote:

No and you are probably misunderstanding what this function was/is for (I know I did when I first saw it and thought why would I use that). It's for resetting the value to its original context specific value, one that can't be handled by the Write function.

 

Take a look here for more info if you are interested...

 

 

 http://qt-project.org/doc/qt-5.0/qtcore/properties.html






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.