Book Image

Learn Qt 5

By : Nicholas Sherriff
Book Image

Learn Qt 5

By: Nicholas Sherriff

Overview of this book

Qt is a mature and powerful framework for delivering sophisticated applications across a multitude of platforms. It has a rich history in the Linux world, is widely used in embedded devices, and has made great strides in the Mobile arena over the past few years. However, in the Microsoft Windows and Apple Mac OS X worlds, the dominance of C#/.NET and Objective-C/Cocoa means that Qt is often overlooked. This book demonstrates the power and flexibility of the Qt framework for desktop application development and shows how you can write your application once and deploy it to multiple operating systems. Build a complete real-world line of business (LOB) solution from scratch, with distinct C++ library, QML user interface, and QtTest-driven unit-test projects. This is a suite of essential techniques that cover the core requirements for most LOB applications and will empower you to progress from a blank page to shipped application.
Table of Contents (11 chapters)

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 identifier contentFrame so that we can reference it elsewhere in the QML, and we specify which child view...