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

settext doesnt work when label is in second page of navigation pane

Hi ,

 

My application uses a navigationpane which contains two pages. Have label in Page2. But when I try to settext of that label,it doesn't work. All objectnames are set and page2 is as attachedobject of page1.

 

Here is cpp code

 

 AbstractPane *root = qml->createRootObject<AbstractPane>();

       page2 = root->findChild<Page*>("page2");

       lbl = page2->findChild<Label*>("lbl");

       lbl->setText("set label text");

Rujuta Trivedi
Developer
BBSJdev
Posts: 6,118
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: settext doesnt work when label is in second page of navigation pane

Have you checked to see if the findChild() function is returning a valid object, my guess is that it won't be.

 

Check the log as well.

 


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.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: settext doesnt work when label is in second page of navigation pane

It doesn't. But it doesn't crash there. I have added page2 as attachedobjects. Why still it doesn't find it
Rujuta Trivedi
Developer
BBSJdev
Posts: 6,118
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: settext doesnt work when label is in second page of navigation pane

Possibly because its not actually attached to the display tree when you make the call.


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.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: settext doesnt work when label is in second page of navigation pane

Can you please help? 

 

Page {

    Container {

        Button{

            text:"click"

            onClicked:{

                var page = page2.createObject();

 

                nav.push(page)

            }

        }

    }

    attachedObjects:[

        ComponentDefinition{

            id:smileytongue:age2

           // objectName:"page2"

            source: "Page2.qml"

        }

    ]

}

 

When button is clicked the page2 is loaded. What should I do to attach it at beginning.

Rujuta Trivedi
Developer
BBSJdev
Posts: 6,118
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: settext doesnt work when label is in second page of navigation pane

I think maybe you can look at the problem from a difficult angle.

Keep the code you have and make a call in the second page to your app to update the label.

 


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.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: settext doesnt work when label is in second page of navigation pane

I have tried this. Made a method in cpp. called method from PAge2 on oncreationcompleted but still it doesnt display

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

Re: settext doesnt work when label is in second page of navigation pane

Can someone direct me to sample/example which is of same scenario?

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

Re: settext doesnt work when label is in second page of navigation pane

Now I get the findchild work. I 'm also able to settext and lbl.text() returns the proper text but the problem is the text is not updated in UI.what should i do to update that?

Rujuta Trivedi
Developer
BBSJdev
Posts: 6,118
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: settext doesnt work when label is in second page of navigation pane

Can you post the code you have so far as there could be many reasons, please use the 'Insert Code' button (the clipboard with a C on it) for clarity when you do.

 


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.