Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Load new View

$
0
0
Hi there, i’m developing an android app. My qml file look like this: //timeline.qml import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Dialogs 1.1   ApplicationWindow {     id: applicationWindow1     visible: true     width: 1200     height: 1920     title: qsTr("whatsOn")     Loader { id: pageLoader }     signal qmlSignal(string msg)       menuBar: MenuBar {         id: theMenu         objectName: "menuBar"           Menu {             title: qsTr("File")             MenuItem {                 objectName: "menItemName"                 text: qsTr("Einstellungen");                 // onTriggered: applicationWindow1.qmlSignal("Hello from qml“) // or                 onTriggered: pageLoader.source = "MyItem.qml"             }             MenuSeparator {}             MenuItem {                 text: qsTr("Exit")                 onTriggered: Qt.quit();             }         }     }     // ... and I want to load this qml file: //MyItem.qml import QtQuick 2.0 import QtQuick.Controls 1.2   Rectangle {     width: 1200     height: 1920     anchors.fill: parent     objectName: "rect"           Button {         id: button1         x: 300         y: 200         text: qsTr("Button Test TEst ")       } } I’m trying to load a new qml file if the MenuItem is pushed. In the above code you can see two alternatives (see onTriggered): I tried to load a new qml in my c++ code (with QQmlApplicationEngine) and I also tried to load a new qml file with the page loader. The first alternative does’t work for me. The second works but the MyItem.qml doesn’t cover the first view, it just add another button to the timeline.qml. I also tried to replace the Rectangle with a ApplicationWindow but it doesn’t work. How can I do this? What is the best practice to load a new qml file? Can someone help?

Viewing all articles
Browse latest Browse all 4972

Latest Images

Trending Articles



Latest Images