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
Posts: 100
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none
Accepted Solution

confused with Page, AbstactPane and GroupDataModel

Hi there,

 

I have an app that has 3 containers showing different content (2 show a html-page, 1 a GroupDataModel).

 

The pages UI is written in QML, but I create the page in C++ and fill it there. Here are the important parts of my code:

// applicationUI.cpp

Page* ApplicationUI::doLoadPageDetails(QString fn) { QmlDocument *qml = QmlDocument::create("asset:///PageDetails/PageDetails.qml").parent(this); qml->setContextProperty("app", this); qml->setContextProperty("minutesData", &AMinutesData); Page *newPage = qml->createRootObject<Page>(); AbstractPane *root = qml->createRootObject<AbstractPane>();

GroupDataModel *contactModel = root->findChild<GroupDataModel*>("contactModel");

// ------ FILL PAGE WITH CONTENT Application::instance()->setScene(newPage); return newPage; }

 Now I open a file from the file browser directly all information is shown in the app like supposed but the back button is missing.

 

When I take away the AbstractPane the back button is there but of course the contacts in my GroupDataModel aren't shown. Can anybody tell me how I can integrate the GroupDataModel to my UI without loosing the back button?

Or why the back button is missing when I'm using an Abstract Pane here? Does the AbstractPane don't have a back button and then "overwrite" the back button?

Developer
Posts: 16,682
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: confused with Page, AbstactPane and GroupDataModel

this looks like a duplicate to http://supportforums.blackberry.com/t5/Native-Development/button-to-main-page/m-p/2879056#M63082

please open only one thread per issue.

----------------------------------------------------------
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: 100
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none

Re: confused with Page, AbstactPane and GroupDataModel

Sorry.

 

I thought because it's not completely the same issue I should start a new thread.

 

In the thread you linked I asked how - when I open a file in my app from the filebrowser - I can get a back button to the main page of my app.

 

Now I just want the standard back button to the filebrowser which I lose when I add an AbstractPane to my page.

Developer
Posts: 16,682
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: confused with Page, AbstactPane and GroupDataModel

why use a pane at all? you can use a page as root element.
----------------------------------------------------------
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: 100
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none

Re: confused with Page, AbstactPane and GroupDataModel

[ Edited ]

I thought so too. But when I change

 GroupDataModel *contactModel = root->findChild<GroupDataModel*>("contactModel");

 to

 GroupDataModel *contactModel = qml->findChild<GroupDataModel*>("contactModel");

 and then try to open a file from the file browser I get the message "Unable to open the file".

 

And when I go to the main page of my app and open a file there the app crashes when it wants to add the first contact to the contactmodel.

for (int i = 0; i < contacts; i++) {
	contactModel->insert(
		new Contact(
			*contact properties*
)
);
}

 

Developer
Posts: 100
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none

Re: confused with Page, AbstactPane and GroupDataModel

Okay. Apparently for a DataModel you need an AbstractPane not a Page. Is this correct?

When I use it like here:

// applicationui.cpp

Page* ApplicationUI::doLoadPageDetails(QString fn) { QmlDocument *qml = QmlDocument::create("asset:///PageDetails/PageDetails.qml").parent(this); qml->setContextProperty("app", this); qml->setContextProperty("minutesData", &AMinutesData); Page *newPage = qml->createRootObject<Page>(); AbstractPane *root = qml->createRootObject<AbstractPane>(); GroupDataModel *contactModel = root->findChild<GroupDataModel*>("contactModel"); // --- fill contactModel with contacts Application::instance()->setScene(root); return newPage; }

 All informations are shown in my app view.

 

But the back button to the previous page is missing. When I delete "Application::instance()->setScene(root);" I see all informations but the contacts. And the back button is there again.

 

So the setScene function overwrites/deletes the back button. Is this correct?

Developer
Posts: 100
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none

Re: confused with Page, AbstactPane and GroupDataModel

Okay. I "solved" the problem by going another way.

 

I wrote a C++ function that gives me a GroupDataModel.

 

Then I fill this GroupDataModel with content and call the C++ function in QML.

 

It's all described here:

http://deanlogic.com/blog/2013/09/20/datamodel-change-trigger/