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
MADdev
Posts: 35
Registered: ‎12-12-2013
My Device: Blackberry Z10

calling the datamodel globally

Hi all,

 

I wanted a datamodel object globally across the qml pages.

I querried from sqlite and result stored in datamodel . this same datamodel values i wanted to access from page 3 , page 4 etc. (how to make that datamodel object available globally)

Please use plain text.
Developer
simon_hain
Posts: 16,137
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: calling the datamodel globally

You could make it available in your main.qml, for example.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Developer
MADdev
Posts: 35
Registered: ‎12-12-2013
My Device: Blackberry Z10

Re: calling the datamodel globally

[ Edited ]

Hi simon,

 

  can you please eloberate.. I am new to blackberry so please suggest some examples on this..

 

Thanks

Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: calling the datamodel globally

What Simon is saying is that you could create your dataModel in the main.qml, if you then give it an id it should be accessible from any qml file after that by referencing that id.

 

So if you are using a navigationPane for instance you could reference it by;

 

      <navigationPaneId>.<dataModelId>

 

in every page you push on to the stack.

 

Alternatively you can use a Qt global variable

 

      Qt.dm = <dataModelId>


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
New Developer
MADdev
Posts: 35
Registered: ‎12-12-2013
My Device: Blackberry Z10

Re: calling the datamodel globally

 

 

Got error

TypeError: Result of expression 'navigationPane.defaultModelMain' [undefined] is not an object

 

Thanks

Please use plain text.
Developer
simon_hain
Posts: 16,137
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: calling the datamodel globally

where specifically do you get this error?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.