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
Contributor
Posts: 31
Registered: ‎09-25-2012
My Device: N/A
My Carrier: Rogers
Accepted Solution

QML property set after onCreationComplete is called?

Hey all,

 

I am attempting to send an ID from one QML page into another using properties. On the second page i want to set a listview with the corresepoding data for the ID which was passed along.

 

Here is the top of the page thats being created and has the 

 

Page {
property alias workoutname: root.workoutName
property alias workoutid: root.workoutID

 

This is the container which holds the list view

 

Container {
id: root
property int workoutID: -1
property variant workoutName: ""

 

This is the onCreationComplete of the Page which has the ID passed into it

 

onCreationCompleted: {
segmentList.dataModel = _Dal.GetListOfWorkoutSegments(root.workoutID);
}

 

The problem is when onCreationComplete is called the root.workoutID is still -1 instead of the value that was set when i created the page?

 

Page creation below.

 

var page = workoutPage.createObject();
page.workoutid = id
page.workoutname = name
homeNavigationPane.push(page);

 

I am adding these pages through a ComponentDefinition.

 

 

Thank you in advance.

 

-J

 

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: QML property set after onCreationComplete is called?

this is expected behaviour

 

you can do it this way:

 

var page = workoutPage.createObject();
page.workoutid = id
page.workoutname = name

page.init()
homeNavigationPane.push(page);

 

...and inside yopur page you have a

function init(){}

where you can use your properties

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Contributor
Posts: 31
Registered: ‎09-25-2012
My Device: N/A
My Carrier: Rogers

Re: QML property set after onCreationComplete is called?

thank you that worked
Developer
Posts: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold
My Carrier: Turkcell

Re: QML property set after onCreationComplete is called?

Thanks ekke, your reply helped me, too.

 

But I wonder why that is the expected behaviour. Wouldn't one expect to have all the properties' values set when "onCreationCompleted" is called?

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: QML property set after onCreationComplete is called?

onCreationCompleted signal is sent exactly when all controls are created

 

setting the properties before or while creating controls would be a kind of catch-22

setting properties sgnals myPropertyChanged where you can change controls or behaviour of controls, so they must be created before

mixing this would bring you in trouble

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Highlighted
Developer
Posts: 149
Registered: ‎04-23-2011
My Device: BlackBerry 9700 Bold
My Carrier: Turkcell

Re: QML property set after onCreationComplete is called?

Dear ekke, thank you for the explanation.

 

 

Best Regards,

 

burakk