Hello.

I am writing a mobile application on Qt 5.4. For the description of the interface took QML. There was the following task.
There are two windows, a parent and a child. Accordingly, the child window is called from the parent.

It is required to call the child window so that when you click the back button on the OS Androyd, the application returns to the parent window.

With such a call to the child window, the back button exits the application.

var component = Qt.createComponent("ChildWnd.qml") var window = component.createObject(root) window.show() 

    4 answers 4

    See an example of Touch Gallery .

    My Window on Android does not work, only Dialog works. But there are also problems with the placement of components. StackView was the best option.

      Usually, in such cases a reference to the parent is passed to the child window. And children already use parent methods show and hide.

      • The problem is not that I do not pass the link to the parent. New Actvity is not created, the window opens on top of the current one. I want to use the native navigation of Anroyd. - Sergey Kostin pm

      one more vote for StackView . I tried several options myself, incl. Popup of controls 2 , but it didn’t fit me either, although it’s very personal.

      • Your answer pulls the maximum to the comment. - AK ♦

      Unfortunately, in android you can not open a "new" window, it is one. But you can reload the old one with a different markup; for this, use the slot in c ++ connected to qml. There you call a private slot through

       QUrl url(str); QMetaObject::invokeMethod(this, "loadnewurl", Qt::QueuedConnection, Q_ARG(QUrl, url)); 

      Already in this slot, you access QQuickView if the program crashes in the first one, for one stream.

      You can use my example on github, https://github.com/tripolskypetr/qmlloadnewmarkup