[SOLVED]: QMenu hide/show actions.
-
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.
-
QActions do have a visible property, don't they?
-
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!
-
I found this while searching how to hide a QMenu itself, you do this with:
@menu->menuAction()->setVisible(false)@
-
I found this while searching how to hide a QMenu itself, you do this with:
@menu->menuAction()->setVisible(false)@