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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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

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

NavigationPane {id:nav
   Page1{}
   attachedObjects:[
       Page2{
           id:page2
           objectName:"page2"
       }
   ]
   }

 Above is main.qml

 

Page {
   
    property alias pagetxt:lbl.text
    Container {
        Label{
            id:lbl
            objectName:"lbl"
          //  text:"lbl"
            onTextChanged:{}
        }
    }
   }

 PAge2

 

And below is cpp code

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

 lbl = root->findChild<Label*>("lbl");
 lbl->setText("set text from here");
 
page2->setProperty("pagetxt","set text from property");
qDebug()<<"got text?????"<<lbl->text();

 I got text "set text from here" in console

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

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

Was it wrapped around an error or warning message?

 

Have you defined lbl as Label* lbl?

 

Does lbl = page2->findChild() return a valid object?

 


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: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

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

Try changing this,

 

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

 

to this,

 

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


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

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

changed it. It returns value set by setproperty in console but doesnt update UI

Rujuta Trivedi
Highlighted
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

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

Debugging by forum is absolutely a nightmare.

 

I don't have the time right now to write an example so either learn how to debug your own code or wait for someone to write an answer for you.

 

 


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,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

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

Hi,

If findChild returns a non-NULL value, make sure you aren't instantiating the pane twice and modifying a second copy.

If you post a complete code (full QML-s + relevant C++ file) we may be able to spot the error.

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

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

[ Edited ]

@BBSJDev thank u for helping me so far.Actually I'm not able to find anything while debugging,everything is initializing,using properly,lbl returns text it just doesn;t display on UI.

@Zmey Here is the total project. Please guide me to solve

Rujuta Trivedi
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

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

1) In main.qml two pages are created: Page1 and Page2 (with id 'page2').

2) In applicationui.cpp you set the text on Page2 (with id 'page2').

3) When the button is pressed on Page1, another instance of Page2 is created (with id 'page1') and pushed into NavigationPane. This second copy of Page2 doesn't have any text set.

The first instance ('page2') is never displayed.

A possible way to fix this:

1) Remove attachedObjects: [ Page2 ... in main.qml

2) After creating the page from ComponentDefinition, call a helper function in C++ to set the text. Pass the page as a parameter to this function.

Note that you can't do this in applicationui.cpp because the page will not exist at this step.

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

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

Thanks a lot Zmey. How can I pass the page object to c++ method?

 

onClicked:{

                var page = page1.createObject();

               _app.callmethod(page)

                nav.push(page)

            }

 

Is it right?

 

it gives error  Error: Unknown method parameter type: Page* 

Rujuta Trivedi
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

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

That's correct. You'll also need to make the corresponding changes in .h:

 

    void callmethod(bb::cascades::Page *page);

And .cpp:

 

void ApplicationUI::callmethod(Page *page){
  Label *myLabel = page->findChild<Label *>("lbl");
  myLabel->setText("hyihh2");
}

I've changed Label declaration to be local. Member variable is not required.

 


Andrey Fidrya, @zmeyc on twitter