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
apascual
Posts: 26
Registered: ‎07-23-2012
My Device: bb10 dev alpha

Tabs + Sql

Hello people,

 

I want add SQL in a Tab, I have:

 

	QmlDocument *qmlDocument= QmlDocument::create().load("home.qml");
	qmlDocument->setContextProperty("tabs", this);
	root = qmlDocument->createRootNode<TabbedPane>();
	Application::setScene(root);

 

I've looked at the sample application "quotes"

 

bool QuotesApp::loadQMLScene()
{

    QmlDocument *qmlDocument = QmlDocument::create().load("main.qml");

    if (!qmlDocument->hasErrors()) {
        qmlDocument->setContextProperty("_quoteApp", this);
        NavigationPane* navigationPane = qmlDocument->createRootNode<NavigationPane>();

        if (navigationPane) {
            QVariantList sqlData = mQuotesDbHelper->loadDataBase("quotes.db", "quotes");

            if (!sqlData.isEmpty()) {
                mDataModel = navigationPane->findChild<GroupDataModel*>("quotesModel");
                mDataModel->insertList(sqlData);
                mListView = navigationPane->findChild<ListView*>("quotesList");
            }
            Application::instance()->setScene(navigationPane);
            return true;
        }
    }

    return false;
}

I tried to merge code for add sql in my code, but NavigationPane have conflict with TabbedPane. How i can do it properly?

 

Thank you all :smileyhappy:

Please use plain text.
Developer
ekke
Posts: 1,544
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Tabs + Sql

you cannot add a TabbedPane to a NavigationPane

 

But you can start with a TabbedPane and then use NavigationPanes for the Tabs to manage a stack of Pages on top.

 

Also you can use Sheets for extra workflows on top

 

also you can have CustomDialog

 

the only thing not working is: TabbedPane on top of NavigationPane

 

At first I also wanted to have NavigationPane and then add TabbedPanes and realized that this doesn't work (Beta 2)

 

Now my StartPage has some Tabs at the bottom - all other pages following have all Tabs in the sidebar to navigate through the app.

many Actions cause to push a NavigationPane.

(Attention: there's a bug yet where pop() a Page from NavigationPane deletes the object. - I have reported an Issue about this)

 

feel free to try my app (from AppWorld ODS Developer Preview) or Sources at Github:

https://github.com/blackberry/opendataspace-cascades

 

ekke

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

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Contributor
apascual
Posts: 26
Registered: ‎07-23-2012
My Device: bb10 dev alpha

Re: Tabs + Sql

Thanks for reply me again ekke! I'm glad to see you again

 

But my problem is where I put the code for load the database, in the start? in only one Tab with his NavigationPane? all of the examples I saw the initial database code is in the Constructor of the app.

 

I think the initial sql code has to be in the contructor but I dont know how "make it" with tabs.

 

Thanks again!

Please use plain text.
Developer
ekke
Posts: 1,544
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Tabs + Sql

you can ask your TabbedPane to find a child

(same as the code using NavigationPane)

 

it depends from your app, your use-cases, where to place code.

do you have a static model ? or will it change ?

think about slots and signals to communicate

and actions calling code in C++

and and and

 

no easy single answer .... als always:

it depends..... ;-)

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

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
BlackBerry Development Advisor (Retired)
gperry
Posts: 138
Registered: ‎05-11-2012
My Device: Developer

Re: Tabs + Sql

Did these suggestions help you progress?

 

Graham

Please use plain text.
Contributor
apascual
Posts: 26
Registered: ‎07-23-2012
My Device: bb10 dev alpha

Re: Tabs + Sql

Hello, i'm looking the weather guesser app, that app have Tabs + Sql integrated.

 

But thanks for reply :smileyhappy:

Please use plain text.
BlackBerry Development Advisor (Retired)
gperry
Posts: 138
Registered: ‎05-11-2012
My Device: Developer

Re: Tabs + Sql

That is a pretty good sample; hope it helps

 

Graham

Please use plain text.
Developer
Zukka
Posts: 201
Registered: ‎05-08-2012
My Device: PlayBook 64 Gb and Z10 LE

Re: Tabs + Sql

Hello to all. I have a problem with the display of a SQL database in a ListView.
I debugged the code and works, Db is loaded correctly, but when it needs to populate the ListView crashes the app.
The app is formed by a tabbedpane and for each tab I have a QML file.
I noticed two anomalies:
the first is that in QVariantList highlighting it exits "typedef QList <QVariant> QVariantList;"
and the second on
SQLData out "inline QList (const QList <T> & l): d (ld) {d-> ref.ref () if (! d-> sharable) detach_helper ();}" instead of "QVariantList SQLData = mPesoModel-> loadDataBase ("peso.db", "weight"); "

In other words I can not understand how to launch the app from main.qml and view the file in Db Dati.qml (third tab of my app)
This code does not work:

if (tabs) {

  QVariantList SQLData = mPesoModel-> loadDataBase ("peso.db", "weight");

if (! sqlData.isEmpty ()) {
mDataModel = tabs-> findChild <GroupDataModel*> ("mioPesoModel");
mDataModel-> insertList (SQLData) / / ERROR!
mListView = tabs-> findChild <ListView*> ("mioPesoList");
}
Application :: instance () -> setScene (tabs);
return true;

 

 

_______________________________________________

If U like my post click on LIKE :smileywink:
Please use plain text.
Developer
Zukka
Posts: 201
Registered: ‎05-08-2012
My Device: PlayBook 64 Gb and Z10 LE

Re: Tabs + Sql

I see Weather guesser App example but use a dataModel only for display a popolate database, I need to edit, add and remove data from database.

_______________________________________________

If U like my post click on LIKE :smileywink:
Please use plain text.
Developer
Zukka
Posts: 201
Registered: ‎05-08-2012
My Device: PlayBook 64 Gb and Z10 LE

Re: Tabs + Sql

Now I copy Quotes App example in a new project, add in file quotes.pro LIBS   += -lbbdata and I retrive in quotes.cpp the same proplem in "sqlData" .. I add other code in .pro file?

_______________________________________________

If U like my post click on LIKE :smileywink:
Please use plain text.