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
unbreakable
Posts: 71
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.

Please use plain text.
Developer
Benecore
Posts: 396
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: T-Mobile

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
Please use plain text.
Developer
simon_hain
Posts: 15,870
Registered: ‎07-29-2008
My Device: Z10 LE
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
Please use plain text.
Developer
unbreakable
Posts: 71
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!

Please use plain text.
Developer
Benecore
Posts: 396
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: T-Mobile

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
Please use plain text.
Developer
unbreakable
Posts: 71
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!

Please use plain text.