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: 384
Registered: ‎08-12-2008
My Device: 8700
Accepted Solution

How to connect Button Click event to NavigationPane.popAndDelete within QML

Hi All,

 

I know to connect my button click event to NavigationPane.popanddelete within native SDK,

 

I want to implement this function within QML, How to implement it.

 

My QML struct is something like this:

 

P

MyHeader.QML

Container{
   Button{
     objectName:"BackButton"
     onClicked:..//how to write here
   }
}


MyPage.QML

Container{
   MyHeader{
   }
   Container{
   }
}


within C++

            QmlDocument *qml = QmlDocument::create("MyPage.qml");
            AbstractPane *mypage= qml->createRootNode<AbstractPane>();
           // Button *button = alertPage->findChild<Button*>("BackButton");
            //QObject::connect(button,SIGNAL(clicked()),this,SLOT(onPreviousClick()));
           m_pagePane->push(mypage);

 Thanks in advance...

Retired
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: How to connect Button Click event to NavigationPane.popAndDelete within QML

Hi there,


First, I want to make sure you know about the pane properties in QML. If you have inserted a page into your navigation pane and wish to have a back button that feels natural, you can use the following code within your Page {} QML definition:


paneProperties: NavigationPaneProperties {
        backButton: ActionItem {
            title: "Back"
            onTriggered: {
                _navPane.pop ();
            }
        }
    }

This will insert a bottom bar populated with a Back button following a consistent style.


If you wish to trigger the pop event from within the QML document via manual button (not from the above solution), in your Button's onClicked property, you can simply call pop on your navigation pane's handle.


e.g.
Button {
            id: buttonTest
            objectName: "buttonTest"
            text: "text"
            onClicked: {
                _navPane.pop ();
        }

Please note that in both cases, you must have exposed the "_navPane" handle in your C++ code with the following calls (assuming that m_SidePaneContentQML is the name of your page containing the back button):


m_SidePaneContentQML = QmlDocument::create().load("SidePane/SidePane.qml");
m_SidePaneQmlContext = m_SidePaneContentQML->documentContext();
m_SidePaneQmlContext->setContextProperty("_navPane", m_Nav);

In this case, m_Nav would be the navigation pane you are using.

Let me know if you need more information, I am glad to help.

Good luck!

Martin

Retired
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: How to connect Button Click event to NavigationPane.popAndDelete within QML

Hi Jeff,

 

I wanted to follow-up on this thread. Has my response helped you progress?

If you need clarification or anything else please let me know.

 

Cheers,

 

Martin

Highlighted
Developer
Posts: 384
Registered: ‎08-12-2008
My Device: 8700

Re: How to connect Button Click event to NavigationPane.popAndDelete within QML

[ Edited ]

Hi Martin,

 

Sorry to respond late.

 

I tried it out yersterday, and it works great.

 

and it makes me more clear about what setContenxt does.

 

just curious, if there is a way to set item title through setContenxt...maybe this one is too greedy.

 

Thanks, i am going to progress next step, backbround thread..

 

BTW, where I can find some documention about how to keep application running all the time.