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. Hide Menu Items in QML
Qt 6.11 is out! See what's new in the release blog

Hide Menu Items in QML

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 4 Posters 3.5k Views 3 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.
  • D Offline
    D Offline
    DivyaMuthyala
    wrote on last edited by
    #1

    Hi,

    I had my gui with menu items like file,tools,settings etc.
    I want to hide one of the menuitem in that, so how to hide it.

    Please give me the solution.

    Thanks in advance

    ekkescornerE 1 Reply Last reply
    0
    • D DivyaMuthyala

      Hi,

      I had my gui with menu items like file,tools,settings etc.
      I want to hide one of the menuitem in that, so how to hide it.

      Please give me the solution.

      Thanks in advance

      ekkescornerE Offline
      ekkescornerE Offline
      ekkescorner
      Qt Champions 2016
      wrote on last edited by ekkescorner
      #2

      @DivyaMuthyala I only worked with QtQuickControls2 MenuItems.
      You cannot make the MenuItiem invisible.
      I have some situations, where Menus are created dynamically (depends from context and user-policies / rights)
      thx to a tip @jpnurmi I manage this with a Repeater.
      Use a data model with text and a ID - then you can create the MenuItem from the model and onTriggered(){if id == 42 doSomething(), ...}
      Hope this gives you an idea
      Menu { Repeater { .... } }

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.9 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

      1 Reply Last reply
      0
      • jpnurmiJ Offline
        jpnurmiJ Offline
        jpnurmi
        wrote on last edited by
        #3

        Qt Quick Controls 2 Menu presents its items using a ListView from Qt Quick, which unfortunately doesn't support hiding items. As a workaround, the height of a hidden list item can be set to 0, though.

        1 Reply Last reply
        0
        • Pradeep P NP Offline
          Pradeep P NP Offline
          Pradeep P N
          wrote on last edited by
          #4

          @DivyaMuthyala
          MenuItems do have visible property which you can set based on your requirement.

          menuBar: MenuBar {
              Menu {
                  title: qsTr("File")
                  MenuItem { text: qsTr("&Open"); visible: false }
                  MenuItem { text: qsTr("Exit"); visible: false }
              }
          }
          

          Pradeep Nimbalkar.
          Upvote the answer(s) that helped you to solve the issue...
          Keep code clean.

          1 Reply Last reply
          2
          • D Offline
            D Offline
            DivyaMuthyala
            wrote on last edited by
            #5

            Hi pradeep,

            Thanku for your answer, its very helpful.

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved