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. Help connecting a menu item to a QML page
Forum Updated to NodeBB v4.3 + New Features

Help connecting a menu item to a QML page

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 2 Posters 579 Views 1 Watching
  • 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.
  • N Offline
    N Offline
    nunomcarv
    wrote on last edited by
    #1

    Hi,

    I am a newbie so I apologize in advance if my question is obvious.
    I want to create a menu with several itens that once triggered open an existent QML page, for example the page "Apresentacao". Why doesn't it works?
    MenuBar {
    Menu {
    title: qsTr("A empresa")
    Action { text: qsTr("Apresentação..."); onTriggered: Apresentacao } //The page Apresentacao exists in the same directory
    Action { text: qsTr("Second Page") }
    Action { text: qsTr("Third Page...") }
    MenuSeparator { }
    Action { text: qsTr("&Quit") }
    }
    I also have another question. How do I can select multiple pics so the user can view them in swipe mode?

    Thanks in advance.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @nunomcarv said in Help connecting a menu item to a QML page:

      onTriggered: Apresentacao

      That expression does not do anything. You need to use a Loader to load this page, or put it in StackView and open correct index when the action is clicked.

      (Z(:^

      N 1 Reply Last reply
      2
      • sierdzioS sierdzio

        @nunomcarv said in Help connecting a menu item to a QML page:

        onTriggered: Apresentacao

        That expression does not do anything. You need to use a Loader to load this page, or put it in StackView and open correct index when the action is clicked.

        N Offline
        N Offline
        nunomcarv
        wrote on last edited by
        #3

        @sierdzio Hi,
        I am still unable to solve this.
        Can you provide an example.
        Thanks.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nunomcarv
          wrote on last edited by
          #4

          I've tried this, but still doesn't work:
          MenuBar {
          Menu { title: "File"
          MenuItem {text: "Open";
          Loader {
          id: loader
          focus: true
          }

                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        loader.source = "Apresentacao.qml"
                    }
                }
                Keys.onPressed: {
                    console.log("Captured:",
                                event.text);
                }
          
          
            }
          

          }
          }

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            Here is something:

            Window {
              visible: true
            
              Menu {
                title: qsTr("A empresa")
                Action { text: qsTr("Apresentação..."); onTriggered: loader.source = "Apresentacao.qml" } 
              }
            
            Loader {
              anchors.fill: parent
              is: loader
            }
            }
            

            (Z(:^

            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