Qt World Summit: Submit your Presentation

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.

  • 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":http://doc.qt.nokia.com/qt-components-symbian-1.0/index.html. 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":https://projects.developer.nokia.com/Qt_Complex provides what you need?

    You can also get some inspiration from this QML "based presentation system":http://labs.qt.nokia.com/2011/05/30/a-qml-presentation-system/

  • 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.

  • 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

  • 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.


  • 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.


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

    @// these are declared in the class PageOne header
    // QDeclarativeView *viewer;
    // QDeclarativeContext *context;

    // Bug(s) included
    Q_INVOKABLE void PageOne::load (QString page){

    viewer = new QDeclarativeView; // :BUG: viewer never deleted
    context = viewer->rootContext();
    context->setContextProperty("pageOne", this);


    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

  • 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":projects.developer.nokia.com/pricemhouse 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.

  • Thanks Alice. Will try downloading Qt Complex.

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


  • Hi bsbala,

    could you please show me how to manipulate multiple screens in qt quick or by cpp?

    I have two screens, one is for displaying control menu and the other is for playing media content. I found that there is a way to do in qt4.8 using qws but it is eliminated in qt5 T__T. Now I am stuck.

    Thanks in advance!

Log in to reply