Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [SOLVED]: QMenu hide/show actions.

    General and Desktop
    3
    5
    10709
    Loading More Posts
    • 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
      someone972 last edited by

      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 Reply Quote 0
      • L
        lgeyer last edited by

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

        1 Reply Last reply Reply Quote 0
        • S
          someone972 last edited by

          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 Reply Quote 0
          • M
            mr.exodia last edited by

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

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

            1 Reply Last reply Reply Quote 0
            • M
              mr.exodia last edited by

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

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post