0

I have a right click menu containing submenus. For instance, it looks something like this

man
animal -->
       cat 
       dog

This post here suggests to use action->associatedWidgets(); which returns list of widgets the current action is linked to.

What do i want:

I would like my menu to return animal everytime a cator dog is clicked. Additionally, that the submenu is clicked.

Is it possible to do it without iterating through list of widgets?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
MarKS
  • 494
  • 6
  • 22
  • The reason why is my menu could grow very large with menus and sub-menus. So i was wondering if it is possible to get just the name without iterating through the whole menu every time i perform a right click. Could you please post a brief iteration? – MarKS May 07 '18 at 16:48
  • @eyllanesc Well..not sure how i missed that post. It is clearly a duplicate i suppose. Thank you! – MarKS May 07 '18 at 18:07
  • You can use `action->parentWidget()` and cast it to `QMenu`. Check out the solution from https://stackoverflow.com/a/25301108/7506407 – gar9 May 07 '18 at 17:43

0 Answers0