Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]: QMenu hide/show actions.

[SOLVED]: QMenu hide/show actions.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 12.6k 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.
  • S Offline
    S Offline
    someone972
    wrote on last edited by
    #1

    I'm not sure if this is the right place for feature requests, so if there's somewhere else that I should put it let me know.

    It would be very helpful to be able to hide and show actions in QMenus. For example, I am making a tool that modifies files from an old game. The 3D models can "reference" another model and use its vertex data instead of providing it's own (there are many models that have the same vertices). I have a context menu that appears when you right click on a model name in the list of models. If the model references another then the menu has an action called "Dereference" which gives the model it's own vertex data. If it is not referencing another model it has an action called "Make reference" where it searches through the list of models for a model that has the same vertices. Only one of these two actions is visible at a time.

    I could accomplish this through the insertAction and removeAction functions, but this requires that I keep track of what the previous state was. It would be much easier if I could simply hide and show which ones I need. I also don't want to just disable one or the other, as that is less intuitive since they accomplish similar goals.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      QActions do have a visible property, don't they?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        someone972
        wrote on last edited by
        #3

        Why yes they do, that would definitely do it. I guess this is a case of just not knowing what to look for in the API. Consider this problem solved!

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mr.exodia
          wrote on last edited by
          #4

          I found this while searching how to hide a QMenu itself, you do this with:

          @menu->menuAction()->setVisible(false)@

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mr.exodia
            wrote on last edited by
            #5

            I found this while searching how to hide a QMenu itself, you do this with:

            @menu->menuAction()->setVisible(false)@

            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