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
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: How to load QML documents on the fly from C++

Ah thank you Mr. Garret. I see now that I can use ActionItem to add items to the NavigationPane bar from a tucked away code snippet in the NavigationPane API reference. Although this isn't solving the problem at hand I will definitely be able to use this information, thank you. 

 

Scott

Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: How to load QML documents on the fly from C++

To stay on topic: what would really be nice though is if I could see an example of how to load multiple QML files from C++. I have shown what I am trying to do with the code I posted above.

 

Scott

Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: How to load QML documents on the fly from C++

Ok, first thing's first, your main.qml would need to be a TabbedPane or NavigationPane in order to allow multiple pages to be displayed in a supported manner. After this is done you pretty much have all the code you need already:

 

Loading a QML file as a C++ Object:


QmlDocument *otherQml= QmlDocument::create("yourFile.qml");

QDeclarativeContext *qdc = otherQml->documentContext();

Page *page= otherQml->createRootNode<Page>();

 

Then to push (with reference to root if it is a NavigationPane):

root->push(page);

 

If you don't want to display an ActionBar this can be hidden, but hiding this and removing the native Cascades UI really does break the expected look and feel of a Cascades application.

 

Let me know if you have any difficulties implementing this.

 

 

 

 

 

Garett
@garettBeuk
--
Goodbye everybody!
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: How to load QML documents on the fly from C++

I never considered hiding the ActionBar. Hiding the ActionBar will help to relieve some of the design constraints although it's not totally what I am looking for. Using NavigationPane as my root excludes me from using TabbedPane on later screens (please correct me if I am wrong). This is a bad design constraint to have.

 

Scott

 

 

Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: How to load QML documents on the fly from C++

Hi Scott,

 

Can you elaborate on where this constraint needs to be used within your application? There are options available other than a TabbedPane such as a Sheet, but first I'd need to know what your use case is.

Garett
@garettBeuk
--
Goodbye everybody!
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: How to load QML documents on the fly from C++

For this application, multiple file types can be opened and manipulated. Each file type will (ideally) have its own TabbedPane that will be displayed when the file is opened after a series of screens through NavigationPane navigation. I would like to avoid using SegmentedControl for the tabs but that option is not off the table at the moment. There will also be flows where the screen will have to switch from one TabbedPane to another TabbedPane.

Thanks for the feedback - this is really speeding up development.

Scott
Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: How to load QML documents on the fly from C++

Hi Scott,

 

Can you describe what you would like to have on the other Tabs? So if, for example, you have an image file opened in your app at a given moment, what would each of the Tabs include?

Garett
@garettBeuk
--
Goodbye everybody!
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: How to load QML documents on the fly from C++

The files are essentially databases and the TabbedPanes would be interfaces with manipulating them. The tabs will be responsible for initiating a wide variety of tasks, but in general they will be used for:

 

- manipulating the UI (adding elements to screen, pop and push panes),

- saving data to persistent store

- making network calls

 

Thanks,

Scott

Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: How to load QML documents on the fly from C++

Could you provide info on the navigation paradigm being used? What would be housed on each of the panes?

 

This will help to understand the flow and then hopefully allow me to suggest some alternative approaches, or help generate a use case for a feature request. 

Garett
@garettBeuk
--
Goodbye everybody!
Contributor
nrjg
Posts: 44
Registered: ‎09-14-2012
My Device: BB 10 Dev alpha

Re: How to load QML documents on the fly from C++

Hello

 

Could you explain how add result QDeclarativeItem to Container (e.g.)?