C
Qt Quick Ultralite loader Example
// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial import QtQuick 2.15 import SettingsData import GameState Rectangle { id: root color: SettingsData.backgroundColor readonly property int numberOfPages: 2 property int currentPage: -1 Loader { id: mainView anchors.fill: parent source: "Logo.qml" Connections { target: root function onCurrentPageChanged(currentPage: int) { if (currentPage === 0) { mainView.source = "memory_game/MemoryGame.qml" } else if (currentPage === 1) { mainView.source = "settings/Settings.qml" GameState.running = false } } } } PageButton { id: prevButton anchors.left: root.left height: root.height width: root.width / 10 visible: root.currentPage != -1 icon: "images/previous_page.png" onClicked: { if(--currentPage < 0) { currentPage = numberOfPages-1 } } } PageButton { id: nextButton anchors.right: root.right height: root.height width: root.width / 10 visible: root.currentPage != -1 icon: "images/next_page.png" onClicked: { currentPage = (++currentPage)%(numberOfPages) } } MouseArea { anchors.fill: parent enabled: root.currentPage == -1 onClicked: { root.currentPage = 0 } } }