11-14-2013 03:08 AM
I am not familiar with c++ but I need to use some for my sqldatabase. I have looked at the Quotes, CRUD samples available but I need to tweak some of the bits for my app but, as I am not familiar with it, I am not sure how to.
Basically, I have a C++ class (db_class.cpp, .h) to help me write/edit my sqlite database. The examples given seems to use this to create the main.qml file directly. However, I do not want to do that as I need that main.qml to be created by another class. So the forms dealing with the database class directly would be a few different qml (like add.qml, update.qml), as well as components inside a ListView.
*For example, one of the things I need to do is to create a checkbox for each component in my Listview such that when the user presses a button, it will interact with the database and mark it true/false.
My questions are:
1) So should I use the db_class.cpp to create those multiple qml? If so how do I do that? I know the basic is:
QmlDocument *qml = QmlDocument::create("asset:///add.qml").parent(thi
AbstractPane *root = qml->createRootObject<AbstractPane>();
But if I have a few files that will need to use the class, do I have to repeat all 3 lines? can I still call each *qml?
2) Is there a better way?
I am not sure which of the methods described in https://developer.blackberry.com/native/documentat
Given that all I would need to do is interact with my class to modify the database via submit buttons, what is the best way that I can call on the c++ in qml?
11-14-2013 03:15 AM
11-14-2013 04:11 AM
I am not sure what you meant by create QML in QML. Do you mean to use the c++ to create a .qml file, and then to basically just include it inside another qml file as a Custom qml?
I have tried to do this in the mean time but it is actually causing the entire project to not built at all. It had also marked the line dbHelper *sqldatabase = new dbHelper(); as undefined reference to `dbHelper::dbHelper()'.
#include "applicationui.hpp" #include "dbHelper.h" #include <bb/cascades/AbstractPane> #include <bb/cascades/Application> #include <bb/cascades/QmlDocument> #include <bb/data/SqlDataAccess> #include <bb/data/DataAccessError> #include <bb/system/SystemDialog> #include <QtSql/QtSql> #include <QDebug>
tion *app) :
dbHelper *sqldatabase = new dbHelper();
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(th
// ... default set root code
I did not add anything to the applicationui.hpp
I am not sure what it means...
11-14-2013 04:14 AM
11-14-2013 04:17 AM
11-14-2013 04:34 AM - edited 11-14-2013 04:36 AM
After I cleaned and rebuilt it, it now causes more error including declaring that bb::cascades is not a recognised namespace I have tried rebuilding it twice now, still the same problem!
(although the actual problem: my custom class, is now not throwing up an error by itself)
11-14-2013 04:35 AM
Yes, I have been using ComponentDefinition for the qml files.
I guess my question is, as I have seen from the samples, the 'sub' - qml files usually call on the c++ classes by _classname.someFunction();
For example, I will call on my 'edit.qml' file from my main.qml's ListView. On that page, it will then have a button that, onClicked, will probably trigger '_app.editRecord' or something.
For me, I am confused because in the examples, the 'app' class immediately creates the main.qml, and everything seems to flow from there. I do not want to create the 'main.qml' directly. So I want to INCLUDE the class so that say my 'edit.qml' (and maybe other qml files) can use the same class!
11-14-2013 04:43 AM
11-14-2013 05:48 AM
I guess it is because every single sample app does that, I am not sure what to do when I want to use more than one of these examples. For example, the BBM integration examples seem to want to do that too. I am not familiar enough with C++ to know how to modify at least one of them!
11-14-2013 05:51 AM