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: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone
Accepted Solution

How to update qml component on some action

Hi,

 

I need to display remaining time of charging battery. I tried to set battery_info into context but could not as its not QObject. I need to display real time timing on my qml.How can I do that

Rujuta Trivedi
Developer
Developer
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: How to update qml component on some action

You can update a value by using QTimer for example. 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: How to update qml component on some action

You can access the QML components from C++.
-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: How to update qml component on some action

Any reference code/sample on github that does server what I need. Updating UI at specific interval?

Rujuta Trivedi
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: How to update qml component on some action

Any reference code/sample on github that does serve what I need. Updating UI at specific interval?

Rujuta Trivedi
Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: How to update qml component on some action

Since you are obvsiouly working on some sort of "remaining-battery-life"-app. I'll try to explain in general what you can do.

 

First of all you have your loop that checks for the remaining battery time. You can either:

  1. keep looping and settings the UI every loop (Not a good idea!)
  2. register for events and set the UI on every event (Best idea, but not sure if this is possible)
  3. Run the determineBatteryLifeRemaining method every minute and setting the UI. (Alternative to 2)

To update your qml components you can just access them from C++ and set the text. Small example of how to do this:

 

QmlDocument *qml = QmlDocument::create("asset:///MainMenu.qml").parent(this);
navigationPane = qml->createRootObject<NavigationPane>();
TextArea* batteryText = navigationPane->findChild<TextArea*>("batteryText");
batteryText->setText("Nominate ZeZke for BB Elite!");

 

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: How to update qml component on some action

Thanks zezke,I will try 2nd or 3rd option.Will be get back to you if any questionsSmiley Happy Thanks again

Rujuta Trivedi
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: How to update qml component on some action

Can you refer any example for registering an event?

Rujuta Trivedi
Developer
Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: How to update qml component on some action

[ Edited ]

Your best bet would most likely be here concerning events..

https://developer.blackberry.com/cascades/documentation/dev/bps/

 

There is also a tutorial link at the bottom of the page as an example..

 

--Edit--

Also for your viewing pleasure, here is another tutorial which utilizes the QTimer class with intervals...

https://developer.blackberry.com/cascades/documentation/dev/signals_slots/signals_slots_set_up_proje...

Highlighted
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: How to update qml component on some action

Did it using registering event

Rujuta Trivedi