StackView

Our child views will be presented via a StackView component, which provides a stack-based navigation model with built-in history. New views (and views in this context means pretty much any QML) are pushed onto the stack when they are to be displayed and can be popped off the stack in order to go back to the previous view. We won’t need to use the history capabilities, but they are a very useful feature.

To gain access to the component, we first need to reference the module, so add the import to MasterView:

import QtQuick.Controls 2.2

With that done, let’s replace our Text element containing our welcome message with a StackView:

StackView {
    id: contentFrame
    initialItem: "qrc:/views/SplashView.qml"
}

We assign the component a unique ...

Get Learn Qt 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.