Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] How correct using MenuBar, Menu and MenuItem from QML Desktop Component
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How correct using MenuBar, Menu and MenuItem from QML Desktop Component

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 3.0k 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.
  • shavS Offline
    shavS Offline
    shav
    wrote on last edited by
    #1

    Hi everybody!

    I try use MenuBar inside my application and I have a small issue. I can't understand how to detect a click for menu item. The code which I try using for it, looks like this:
    @
    menuBar: MenuBar {
    Menu {
    text: "File"

            MenuItem {text: "Open Log..."}
        }
        Menu {
            text: "Preferences"
        }
        Menu {
            text: "Help"
    
            MenuItem {
                text: "About..."
                onClickedItem: {
                    console.log("About Selected....");
                }
            }
        }
    }
    

    @

    The MenuBar and MenuItem works fine, but when I try to use signals for click I received this error:
    @
    Cannot assign to non-existent property "onClickedItem"
    @

    I checked QML Desktop Components and found this signals for MenuItem:
    @
    signal selectedItem(int index, Rectangle item)
    signal clickedItem
    @

    What signals I must using to select item from menu?

    Update: I found my mistake!

    Mac OS and iOS Developer

    1 Reply Last reply
    0
    • shavS Offline
      shavS Offline
      shav
      wrote on last edited by
      #2

      The correct using of code for click to item menu:
      @
      menuBar: MenuBar {
      Menu {
      text: "File"

              MenuItem {text: "Open Log..."}
          }
          Menu {
              text: "Preferences"
          }
          Menu {
              text: "Help"
      
              MenuItem {
                  text: "About..."
                  onTriggered: {
                      console.log("Clicked!!!!");
                  }
              }
          }
      }
      

      @

      Mac OS and iOS Developer

      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