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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 74
Registered: ‎12-17-2009
My Device: Z30
My Carrier: O2

Re: Calling c++ in qml for sql

I have tried doing so, but I just need some specific guidance as the documents are sometimes quite confusing/incomplete.

 

I have now tried to include the C++ into my application.cpp this way:

dbHelper *sqldatabase = new dbHelper();

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("_sqlDatabase", sqldatabase);

 However, when I try to call it from a second page (which is called onto the navigation stack main.qml), I get the error that there is no such variable.

 

I try to call it from a ListItemComponent :

 

var selected = dataModel.data(indexPath)
 _sqlDatabase.favourite(selected.id_number)

 I am not sure what else I am supposed to do? As far as the cascades docmentation goes, that is all I could make of it.

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Calling c++ in qml for sql

[ Edited ]

If your function does not find on some QML files. Try this on your ROOT file in this case main.qml

onCreationCompleted:{
    Qt.MySql = _sqlDatabase
}

and then use Qt.MySql instead of _sqlDatabase

also make sure that selected.id_number exists

 Hope it helps

 



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: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Calling c++ in qml for sql

list items are a different topic altogether.
this should help:
http://supportforums.blackberry.com/t5/Native-Development-Knowledge/How-to-access-qml-properties-fro...
----------------------------------------------------------
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
Developer
Posts: 74
Registered: ‎12-17-2009
My Device: Z30
My Carrier: O2

Re: Calling c++ in qml for sql

Thanks. Is Qt.Mysql a built in property? Or can .Mysql be any name I want?

 

Some other part of my code is preventing me from trying this out now for the moment, hopefully I can sort it out and try this!

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Calling c++ in qml for sql

MySql can be any name


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
Highlighted
Developer
Posts: 74
Registered: ‎12-17-2009
My Device: Z30
My Carrier: O2

Re: Calling c++ in qml for sql

Thanks, will mark it as the solution once I sort out my other problems and confirm that it works!