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: 21
Registered: ‎04-26-2012
My Device: BlackBerry 9800
My Carrier: BlackBerry

How to get Components properties?

Hi,

I want to access the compomnent properties

like

What is current Label text?

What is current Label width?

What is current List height?

 

i am created these components in QML, and i want to change properties in C++

 

Thank you.

Developer
Posts: 18
Registered: ‎04-28-2012
My Device: Playbook & Dev Alpha
My Carrier: AIS

Re: How to get Components properties?

You have to set objectName to the component in QML. Then in C++ you can use findChild to get the pointer to that component. You can then call property()/setProperty() to that component. For example.

 

Label {
    objectName: "label1"
    text: "label"
}

QmlDocument *qml = QmlDocument::create("test.qml");
Page *page = qml->createRootNode<Page>();
Label *label = page->findChild<Label *>("label1");
label1->setText("hello");
label1->setProperty("...", ...);

 

Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: How to get Components properties?

[ Edited ]

Wrong answer. I deleted my post :-(




--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Retired
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: How to get Components properties?

Pallam_Mudhukar,

Were you able to find what you were looking for with these suggestions?

Highlighted
Retired
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: How to get Components properties?

Please read:

https://developer.blackberry.com/cascades/reference/bb__cascades__layoutupdatehandler.html

and

https://developer.blackberry.com/cascades/reference/bb__cascades__label.html

 

The first link shows how you can get a control's size after layout.   Normally we expect we don't care about the actual sizes but merely request sizes and let the layout do its job.

 

The second link shows Beta2 behaviour for Labels. 

In particular:

The size of the label behaves as follows:

Stuart