PDA

View Full Version : Qml Android open View from MenuItem



Nio74
1st April 2019, 10:10
Good Morning, I have to open a window by cliking in the menu how I do?
13070

this is My QML:


import QtQuick 2.0
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.12

ApplicationWindow {
id: window
width: 500
height: 500



visible:true

Rectangle {
id: rectangle
color: "#212126"
anchors.fill: parent
}


header: ToolBar {

background:Rectangle
{
implicitHeight: 40
color: "beige"
}



RowLayout {
anchors.fill: parent
ToolButton {
text: qsTr("‹")
onClicked: stackView.pop()
}
Label {
text: "App Paolo"
elide: Label.ElideRight
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
Layout.fillWidth: true
}
ToolButton {
text: qsTr("?")
onClicked: {
menu.x = (window.width - menu.width) / 1
menu.y = 10
menu.open()}
}
}
}

ListModel {
id: pageModel
ListElement {
title: "Riparazioni"
page: "Riparazioni.qml"
}
ListElement {
title: "Magazzino"
page: "Magazzino.qml"
}
}
StackView {
id: stackView
anchors.fill: parent
// Implements back key navigation
focus: true
// //Keys.onReleased: if (event.key === Qt.Key_Back && stackView.depth > 1) {
// stackView.pop();
// event.accepted = true;
// }

initialItem: Item {
width: parent.width
height: parent.height
ListView {
model: pageModel
anchors.fill: parent
delegate: AndroidDelegate {
text: title
onClicked: stackView.push(Qt.resolvedUrl(page))
}
}
}
}
StackView {
id: stack
anchors.fill: parent
}

Menu {
id: menu

MenuItem{
text: "Settings"
onClicked: { //Open View help me tank


}


}
}





}

Nio74
2nd April 2019, 05:38
I answer myself I did so and it works:



MenuItem{
text: "Settings"
onClicked: {

stackView.push("Settings.qml")



}