Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android Open a window from menu
Forum Updated to NodeBB v4.3 + New Features

Android Open a window from menu

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 333 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.
  • Nio74N Offline
    Nio74N Offline
    Nio74
    wrote on last edited by Nio74
    #1

    Good Morning, I have to open a window by cliking in the menu how I do?

    0_1554094162377_catturaMenu.JPG

    thi s is my code 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: {
                    stackView.push(Qt.resolvedUrl(Settings))
                }
    
    
            }
        }
    
    
    
    
    
    }
    
    
    1 Reply Last reply
    0
    • Nio74N Offline
      Nio74N Offline
      Nio74
      wrote on last edited by
      #2

      I answer myself I did so and it works, it was too trivial

      
              MenuItem{
                  text: "Settings"
                  onClicked: {
      
                     stackView.push("Settings.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