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
New Developer
Posts: 75
Registered: ‎08-15-2013
My Device: blackberry curve 9630

Navigation Pane Usage:- Blackberry Cascades

Hi All,

 

I am developing a loging screen in cascades using Navigation Pane .

 

Below are my file details

 

login.qml

 

import bb.cascades 1.0
NavigationPane {
id: navigationPane
Page {
titleBar: TitleBar {
title: "My App"
}
Container {
Label {
text: "Please log in"
}
TextField {
id: username
hintText: "User Name"
}
TextField {
id: password
hintText: "Password"
inputMode: TextFieldInputMode.Password
}
Button {
text: "Log in"
onClicked: {
/* if (email.text == "" || password.text == "") {
//display error
alertDialog.show();
return;
}
*/
if (app.checkLogin(email.text, password.text)) {
navigationPane.push(secondPageDefinition.createObject());
} 
}
}
}
/* actions: ActionItem {
* title: qsTr("Second page")
* ActionBar.placement: ActionBarPlacement.OnBar
* 
* onTriggered: {
* navigationPane.push(secondPageDefinition.createObject());
* }
* }*/
}
attachedObjects: [
ComponentDefinition {
id: secondPageDefinition
source: "main.qml"
Page {
Container {
}
}
}
]
onPopTransitionEnded: {
page.deleteLater();
}
}

 

applicationUI.cpp

 

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
	QmlDocument *qmlLogin = QmlDocument::create("asset:///login.qml").parent(this);
	// Creating clipboard instance to store the Cipher Text which can be used for pasting

	qml->setContextProperty("app", this);
	qmlLogin->setContextProperty("app", this);

	// Create root object for the UI
	AbstractPane *root = qmlLogin->createRootObject<AbstractPane>();

	// Set created root object as the application scene
	app->setScene(root);

 

There is one more main.qml file which has the business logic of the application

 

Now when i run this app on blackberry device z10 following error comes and navigation doesn't go beyond login page:

 

 

CS Debugging enabled: false
"Unable to get asset: (/main.qml)."
"Unable to get asset: (/login.qml)."

pushPage : mNavigationStack : ("12")
NavigationPane: NavigationPaneOnFwdTransitionDone: emitting push transition ended for page: 12 client top: 12
exit assetdir_create: false - missing index file, update ide to fix this
exit assetdir_create: false - missing index file, update ide to fix this
exit assetdir_create: false - missing index file, update ide to fix this

 

 


Please help me whats wrong in the code i have written.

 

Thanks & Regards,

 

 

Developer
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Navigation Pane Usage:- Blackberry Cascades

[ Edited ]

I think this is not good :smileywink:

attachedObjects: [
ComponentDefinition {
id: secondPageDefinition
source: "main.qml"
Page {
Container {
}
}
}
]

In ComponentDefinition you can use source (separate file) or inline component as your Page. Using both of them is mishmash.

 

EDIT I:

And also. I don't think this is a good solution

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
	QmlDocument *qmlLogin = QmlDocument::create("asset:///login.qml").parent(this);
	// Creating clipboard instance to store the Cipher Text which can be used for pasting

	qml->setContextProperty("app", this);
	qmlLogin->setContextProperty("app", this);

If you required still shows Login page as default, you don't need create main.qml page in C++, why? In your login page you're using ComponentDefinition for dynamically create main.qml

 

EDIT II:

If you're using NavigationPane in whole of your app, then I suggest you create 3 pages

main.qml - as root component with NavigationPane

LoginPage.qml

and

AfterLoginPage.qml

and as first QMLDocument load only main.qml. After that you have more options to play with UI.



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
New Developer
Posts: 75
Registered: ‎08-15-2013
My Device: blackberry curve 9630

Re: Navigation Pane Usage:- Blackberry Cascades

Hi,

 

Thanks for replying .

 

Well i have a doubt , i used the above approach and in .cpp loaded only one qml and made sure thats rest qml are loaded are through navigation page usage.

 

Well the first edit you suggested in main.qml is not very clear, please specify it. Also after loading one qml file in cpp file i was still getting same error in logs that qml not found.   Please help me in this perspective.

 

Thanks & Regards,

Tushar

Developer
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Navigation Pane Usage:- Blackberry Cascades

In first edit, i meant that create two QML documents is unnecessary. You need to load only onr page in my example
main.qml and inside it create another pages.
For example:
main.qml

NavigationPane{
id: naviPane

// Load first page
LoginPage{
}


attachedObjects:[
ComponentDefiniton{
id: dynamicAfterLoginPage
source: "AfterLoginPage.qml"
}
]
}

If your page does not found. Try to clean project and build it again. Also try look at the content of asset.index file if contains all your qml files


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
New Developer
Posts: 75
Registered: ‎08-15-2013
My Device: blackberry curve 9630

Re: Navigation Pane Usage:- Blackberry Cascades

Hi,

 

Thanks a lot i have implemented the approach suggested by you but this time i am facing a new issue.

 

I have a login.qml where i am using navigation pane for login screen, now after logging in i am redirecting the output to second screen i.e. main.qml but i see that when main.qml is loaded no image is loaded into that qml.

 

The code snippet is as below:-

 

  ActionItem {
            title: "Generate key"
            enabled: app.cryptoAvailable
            ActionBar.placement: ActionBarPlacement.InOverflow
            onTriggered: {
                key.text = app.generate(); // will trigger onchanged...
            }
            imageSource: "asset:///images/g3189.png"

 

 

 

The image is present under images folder in assets

 

also login.qml is as follows:-

 

if (app.checkLogin(username.text, password.text)) {
navigationPane.push(secondPageDefinition.createObject());
}
if (app.checkLogin(username.text, password.text)) {
navigationPane.push(secondPageDefinition.createObject());
}

 

Please tell whats wrong in tgeh code.

Developer
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....

Re: Navigation Pane Usage:- Blackberry Cascades

Try to look at asset.index file if contains your image and also try clean the project.

BTW: For the future i suggest you create another topic for new problem. If somebody will have same issue then will better finds the solution


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 976
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Navigation Pane Usage:- Blackberry Cascades


Benecore wrote:
BTW: For the future i suggest you create another topic for new problem. If somebody will have same issue then will better finds the solution

I was just about to say the same thing to the OP, when I noticed you had already done so.

 

:Rockon:



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.