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
mcl1dev
Posts: 53
Registered: ‎11-06-2013
My Device: PlayBook, Z30-STA100-5, Z10-STL100-3
My Carrier: AT&T
Accepted Solution

Inter-QML communication

Has anyone ever setup communication between multiple QML objects?  It probably is a built-in capability.  I am capturing input from a SystemPrompt and populating a TextField in another QML Object.  I am saving the input to a QSetting before displaying it.  This input can go to multiple QML object so I have set it up as a QProperty in my main module.    I quess I need to setup a Slot/Signal combo to get it to update in all QML Objects, but don't quit know how to go about this.

 

Any recommendations ?

iWm
Please use plain text.
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Inter-QML communication

[ Edited ]

If i understood :smileywink:
Then you only need to set NOTIFY signal to your property and emitting it if data changed.

Q_PROPERTY(int myData READ myData WRITE setMyData NOTIFY myDataChanged)

Then emit myDataChanged signal inside setMyData function. After emit the signal the property is changed in all QML files



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Inter-QML communication

The relevant term here, by the way, is "property binding". There are pages of documentation in Qt and probably the Cascades docs which describe how that works and how to take advantage of it. It makes "inter-QML communication" trivial in many cases.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
mcl1dev
Posts: 53
Registered: ‎11-06-2013
My Device: PlayBook, Z30-STA100-5, Z10-STL100-3
My Carrier: AT&T

Re: Inter-QML communication

I don't think, in this case, that it is a trivial matter... the connection is between a standard QML object (the text field) and a SystemPrompt dialog.  I believe some other mechanisms need to come into play in order to get the string from the dialog.

iWm
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Inter-QML communication

That's important to know I guess. :smileyhappy:

You can retrieve the dialog's result property in the finished() handler (generally that would be a code block marked onFinished: in the SystemDialog object itself) and then put that where you like. If you've got a property on your root object, it's a simple assignment (e.g. root.myProperty = dialog.result) or a mapping of said result to something else like a string.

The binding part is how that property update gets distributed to all the other objects, not necessarily how you get it from the SystemDialog finished() signal. That's how you'd resolve the need expressed in "I quess I need to setup a Slot/Signal combo to get it to update in all QML Objects" but with the "trivial" binding approach.

If this isn't helping, and the docs aren't helping, someone could post some code snippets demonstrating this.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
mcl1dev
Posts: 53
Registered: ‎11-06-2013
My Device: PlayBook, Z30-STA100-5, Z10-STL100-3
My Carrier: AT&T

Re: Inter-QML communication

If you don't mind, I would love to see your  "trivial" binding approach.  Code snippets demonstrating this would be most appreciated.

 

(sorry about the comm lag)

iWm
Please use plain text.
Developer
BBSJdev
Posts: 6,094
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Inter-QML communication

LOL, are you really still stuck on this 5 months later? :smileyhappy:

 

Did you try to just read the property of the SystemPrompt in the finished slot?


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

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
BBSJdev
Posts: 6,094
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Inter-QML communication

[ Edited ]

These links go through how two QML objects can iteract with code examples...

 

http://developer.blackberry.com/native/documentation/cascades/dev/signals_slots/

 

http://developer.blackberry.com/native/documentation/cascades/dev/signals_slots/signals_slots_set_up...

 

[Edit] By the way I wasn't laughing at you above, just the length of time between the OP and response. :smileyhappy:


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

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
mcl1dev
Posts: 53
Registered: ‎11-06-2013
My Device: PlayBook, Z30-STA100-5, Z10-STL100-3
My Carrier: AT&T

Re: Inter-QML communication

This is great, I think this is all I need!

iWm
Please use plain text.