Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML: Simple Multi page app
Forum Updated to NodeBB v4.3 + New Features

QML: Simple Multi page app

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 356 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zeroalpha
    wrote on last edited by
    #1

    Is this the best way to run a multi page app?

    This example has 2 pages that the user can navigate between

    main.qml which hosts the 2 pages

    import QtQuick
    import QtQuick.Controls
    
    ApplicationWindow {
        id: mainWindow
        visible: true
        width: 640
        height: 480
        title: "Main Window"
    
        StackView {
            id: stack
            width: parent.width
            height: parent.height
            initialItem: Qt.resolvedUrl("page2.qml")
        }
    
        Component.onCompleted: {
            stack.replace("page2.qml")
        }
    
    }
    

    page2.qml

    import QtQuick
    import QtQuick.Controls
    
    Item {
        width: 640
        height: 480
    
        Rectangle {
            anchors.fill: parent
            color: "red"
        }
    
        Button {
            id: clicky
            text: "Go to the Blue page"
            anchors.centerIn: parent
            onClicked: {
                stack.replace("page3.qml")
            }
        }
    
    }
    

    page3.qml

    import QtQuick
    import QtQuick.Controls
    
    Item {
        width: 640
        height: 480
    
        Rectangle {
            anchors.fill: parent
            color: "blue"
        }
    
        Button {
            id: clicky2
            text: "Go back to the Red page"
            anchors.centerIn: parent
            onClicked: {
                stack.replace("page2.qml")
            }
        }
    
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved