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
urbanglowcam
Posts: 148
Registered: ‎10-30-2010
My Device: Bold 9930
My Carrier: Verizon
Accepted Solution

OnTrigger link to another QML

[ Edited ]

I tried following the tutorials to see how to use the top-down action bar. Everything works except I can't get the action item to link to a separate QML. The tutorial only shows how to bring up a prompt which is pretty useless to me.

 

Can someone look at the OnTriggered method I have and tell me what I'm doing wrong? I'm trying to link to AboutTab.qml

 

--

 

TabbedPane {

Menu.definition: MenuDefinition {
actions: [
ActionItem {
title: "About"
imageSource: "asset:///images/menuicons/picto-about.png"
onTriggered: {
var page = pageDefinition.createObject();
navigationPane.push(page)
}
attachedObjects: ComponentDefinition {
id: pageDefinition
source: "AboutTab.qml"
}
}
]
}
id: maintab
showTabsOnActionBar: true

 

--

 

The drop down works with the right icon and everything, but clickin git won't do anything.

 

Thanks!

Please use plain text.
Developer
soaman
Posts: 848
Registered: ‎03-03-2011
My Device: Z10

Re: OnTrigger link to another QML

Try two things:
1. add ; after push()
2. move attachedObjects to root component after showTabsOnActionBar line
--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Please use plain text.
Developer
urbanglowcam
Posts: 148
Registered: ‎10-30-2010
My Device: Bold 9930
My Carrier: Verizon

Re: OnTrigger link to another QML

That didn't seem to work. Here is how the code looks now.

 

--

 

import bb.cascades 1.0

TabbedPane {

Menu.definition: MenuDefinition {
actions: [
ActionItem {
title: "About"
imageSource: "asset:///images/menuicons/picto-about.png"
onTriggered: {
var page = pageDefinition.createObject();
navigationPane.push(page);
}
}
]
}
id: maintab
showTabsOnActionBar: true

attachedObjects: ComponentDefinition {
id: pageDefinition
source: "AboutTab.qml"
}

Tab {
id: news
title: "News"
imageSource: "asset:///images/menuicons/picto-news.png"

NewsTab {
id: newstab
}
}

Tab {
id: drivers
title: "Drivers"
imageSource: "asset:///images/menuicons/picto-drivers.png"

....

--

 

I think it has something to do with the navigationPane.push(page);

 

The push method works in the QML within my other tabs, but that's because everything is inside a NavigationPane { that allows the id of navigationPane.

 

This instance is all within a TabbedPane { and when I give it an id of navigationPane, the app gets stuck at the loading screen.

Please use plain text.
Regular Contributor
mazmellow
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon

Re: OnTrigger link to another QML

Sorry if i mistake,

But where is your NavigationPane that has id "navigationPane"? In Tabs?  :smileyindifferent:

Maz

Please use plain text.
Developer
urbanglowcam
Posts: 148
Registered: ‎10-30-2010
My Device: Bold 9930
My Carrier: Verizon

Re: OnTrigger link to another QML

The QML page I'm talking about now is the main.qml. It consists of a TabbedPane that contains everything, so I can't attach an id of NavigationPane or it will break the app.

 

But on each QML (tab pages), it consists mainly of a NavigationPane { with a specific id that allows this to work. So how should I get this to work on the main qml page?

 

I hope I'm making sense..

Please use plain text.
Developer
urbanglowcam
Posts: 148
Registered: ‎10-30-2010
My Device: Bold 9930
My Carrier: Verizon

Re: OnTrigger link to another QML

Basically, I'm trying to find a way to use the top-down action bar and a standard tab list at the bottom.

 

But the Tabs use a TabbedPane { while the top-down action bar uses a NavigationPane {

 

I can't do both.

Please use plain text.
Regular Contributor
mazmellow
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon

Re: OnTrigger link to another QML

Hi urbanglowcam,

Sorry for lately reply, I forget this post. Did you find any solution for your problem?  

I think you must look at a "weatherguesser" demo project. It uses a NavigationPane in Tab likes you. Then you look at a ContinentsPage.qml and try to insert your actions in Page for use navigationPane for push page. :smileyhappy: 

Maz

Please use plain text.
Developer
urbanglowcam
Posts: 148
Registered: ‎10-30-2010
My Device: Bold 9930
My Carrier: Verizon

Re: OnTrigger link to another QML

[ Edited ]

Hi mazmellow. Thank you for getting back to me. I did look at the weatherguesser but I don't think it solved my problem.

 

I don't have any issues with using the NavigationPane method to push pages. That is simple. I am having trouble in my main.qml. I can show tabs at the bottom and have the top-down action bar where you swipe from the top and bring down the menu. But I cannot make the actions from the top-down menu link to another QML page.

 

----

 

import bb.cascades 1.0

TabbedPane {
id: mainTab
showTabsOnActionBar: true

Menu.definition: MenuDefinition {
actions: [
ActionItem {
title: "About"
imageSource: "asset:///images/menuicons/picto-about.png"
onTriggered: {
var page = pageDefinition.createObject();
mainTab.push(page);
}
}
]
}

attachedObjects: ComponentDefinition {
id: pageDefinition
source: "AboutTab.qml"
}

Tab {
id: news
title: "News"
imageSource: "asset:///images/menuicons/picto-news.png"

NewsTab {
id: newstab
}
}

Tab {
id: drivers
title: "Drivers"
imageSource: "asset:///images/menuicons/picto-drivers.png"

DriversTab {
id: driverstab
}
}

 

....

 

----

 

I think there is something wrong in the code that I bolded above. Since it's not within a NavigationPane component, it doesn't work. But if I make it NavigationPane, the tabs will not work.

Please use plain text.
Regular Contributor
mazmellow
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
My Carrier: Verizon

Re: OnTrigger link to another QML

[ Edited ]

Hi, 

Sorry about my misunderstood about your problem (and maybe this post I'm still misunderstood). I think you can use c++ object to call your navigationPane for push a screen. For example, I modify weatherguesser project with bold character like this

 

//weatherguesserapp.cpp

WeatherGuesserApp::WeatherGuesserApp() {

...

mQmlDocument = QmlDocument::create("asset:///main.qml");

...

mQmlDocument->setContextProperty("app", this);   // Use for call function

...

 

if (!mQmlDocument->hasErrors()) {

 

// The application navigationPane is created from QML.

TabbedPane *tabs = mQmlDocument->createRootObject<TabbedPane>();

 

if (tabs) {

mynav = tabs->findChild<NavigationPane*>("continentsNav");   //mynav is a NavigationPane object. You must declare it in weatherguesser.h 

 

Application::instance()->setScene(tabs);

}

}

}

 

void WeatherGuesserApp::testFunction() {   //test funtion, don't forget to add Q_INVOKABLE macro in .h

qDebug() << "testFunction()";

QmlDocument *qml = QmlDocument::create("asset:///TestPage.qml");   // some .qml that start with Page tag

Page *newPage = qml->createRootObject<Page>();

mynav->push(newPage);

}



//ContinentsPage.qml

NavigationPane {

    id: continentsNav

    objectName: "continentsNav"  // for get this NavigationPane object to c++

    Page {

       ...

        }
}

// main.qml

TabbedPane {

    ...

    Tab {
     }

     Tab {

        ContinentsPage {

             ...

        }

     } 

     Tab {
     }

     Tab {
     }
     

     Menu.definition: MenuDefinition {

        actions: [

            ActionItem {

                title: "My Action"

                onTriggered: {

                    console.log("MyActionItem");

                    app.testFunction();      // Call testFunction()

                }

            }

        ]

     }

}

I'm not sure that is this your wanted solution? But from my experience, when I can't access any qml object by using id. I will using c++ object to help.

    

Maz

 

Please use plain text.
Developer
urbanglowcam
Posts: 148
Registered: ‎10-30-2010
My Device: Bold 9930
My Carrier: Verizon

Re: OnTrigger link to another QML

Thank you so much for doing that mazmellow. Unfortunately, I'm not too good with C++ so it will be hard for me to use this.

 

I was hoping there was a way I could do this in pure QML, but I will try my best! :smileyhappy:

Please use plain text.