September 2, 2011

bsbala bsbala
Lab Rat
16 posts

Multiple QML screen handling

 

Hi,

I am in the process of developing a multi screen application for a standalone device using Qt/QML. I tried with QDeclarativeview(Thanks to help from ZapB) to manipulate the property of the QML objects and it worked well.

I have the following questions

1. If suppose I want to load another QML page and want to manipulate the property of the QML objects on the new page, How do I need to change the underlying Qt/C++ layer for the new QML page?

2. What will happen to the previously loaded QML page. Will it be destroyed?

I tried loading QML pages using Loader objects.

Please let me know, if I am not clear here.

Thanks for your help.
BsBala

8 replies

September 2, 2011

ZapB ZapB
Robot Herder
1354 posts

Hey!

If your pages are very heavyweight then yes using Loader items is a sensible approach. To get basic page support you can make use of the Qt Components for Symbian/Harmattan [doc.qt.nokia.com]. See the docs about page based navigation for more info: http://doc.qt.nokia.com/qt-components-symbian-1.0/qt-components-pages-and-navigation-overview.html.

What is your target device by the way?

If you are targeting the desktop or some other embedded device then you need to come up with some method of your own or use another set of components. I’ve not checked but maybe Qt Complex [projects.developer.nokia.com] provides what you need?

You can also get some inspiration from this QML based presentation system [labs.qt.nokia.com]

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

September 2, 2011

mlong mlong
Mad Scientist
1517 posts

You might look at that Page and PageStack components in Qt Components to begin with. They can allow you to have multiple pages on your Qt Quick application, without necessarily destroying pages that are not being viewed.

 Signature 

Senior Software Engineer
AccuWeather Enterprise Solutions
/* My views and opinions do not necessarily reflect those of my employer.  Void where prohibited. */

September 3, 2011

bsbala bsbala
Lab Rat
16 posts

Hi ZapB and mlong,

Thanks for your replies.

The target environment is a medical device thats going to run on linux.

I will go through the links that you have suggested.

The front end QML will not be the core application. A ‘C’ application would be the core. It would control the entire device and the Qt would be the user interface to preset required values and monitor the device. So it is required that the UI takes as much less space as possible

Thanks a lot for your help
Balaji

September 8, 2011

bsbala bsbala
Lab Rat
16 posts

Hi,

I have been trying hard to implement this functionality but could not make any progress. I went through the page and page stacks but could not make out how to change the corresponding C++ objects(Created by inheriting QOBJECT or QDECLARATIVE item and defining the properties using QPROPERTY corresponding to the loaded qml) when a new qml page is loaded from an already existing qml.

Please let me know if I am not clear.

Thanks for your help.

Balaji

September 14, 2011

bsbala bsbala
Lab Rat
16 posts

Hi,

I made some progress on this but I am stuck with a problem. On the first QML, I coded an onclicked element so that, when clicked it invokes a method(the second qml name is passed to this method) a C++ class which inturn emits a screen changed signal to invoke a slot in another class that uses qdeclarative view( with which I display the first qml )and try to load the second qml. This is not loading the qml. Is there a way to reset the declarative view so that I can load the second qml screen with the same declarative view?

Please let me know if I am not clear.

Thanks
Balaji

September 16, 2011

_perza _perza
Lab Rat
1 posts

I have the same problem, so here is something that I have tried, but not very successfully :)

  1. // these are declared in the class PageOne header
  2. // QDeclarativeView *viewer;
  3. // QDeclarativeContext *context;
  4.  
  5. // Bug(s) included
  6. Q_INVOKABLE void PageOne::load (QString page){
  7.  
  8.     viewer = new QDeclarativeView; // :BUG: viewer never deleted
  9.     viewer->setSource(QUrl::fromLocalFile(page));
  10.     context = viewer->rootContext();
  11.     context->setContextProperty("pageOne", this);
  12.     viewer->showFullScreen();
  13. }

Now the problem here is (or, at least one of the problems) that calling this function eats memory, as the viewer is never deleted between successive calls. However, simple delete for the viewer crashes the program, so how to do this properly?

BTW, this method is Q_INVOKABLE as it is called from the current QML page.

br, _perza

September 16, 2011

Alicemirror Alicemirror
Lab Rat
825 posts

Hi,

If you try to download Qt -Complex (thanks ZapB) it is a framework that can be inserted in your application without any changes (and if you don’t use any of the components nothing happens :) ) as a subfolder in your QML main folder. Then take a look to the wiki pages of the project and the code itself: you see that almos all the components are loaded / unloaded and the actual sample application uses the pages to manage the navigation just for cases with huge contents.
In addition, you can download the PMH project sources (formerly Price My House) that has a solution managing a multi page form with 7 different views on the same page. It was the base project where Qt-Complex was initially created.

 Signature 

Enrico Miglino (aka Alicemirror)
Tech Consulting
Islas Baleares, Ibiza (Spain)
http://www.contesti.eu

September 16, 2011

bsbala bsbala
Lab Rat
16 posts

Thanks Alice. Will try downloading Qt Complex.

ZapB – thanks for mentioning it. I will again do a deep dive into Qt Complex.

Thanks
bsbala

 
  ‹‹ Hardware keyboard on simulator. Possible?      OpenGL support with Qt on Tegra2 ››

You must log in to post a reply. Not a member yet? Register here!