PDA

View Full Version : Getting QMenu of selected QAction



snydesc
6th October 2012, 21:53
I have a set of QActions. The same set needs to appear as a sub menu of 3 different menus. Is there a way to get the QMenu used that activated the action?

For example:

I have 3 QMenus:

Insert Before
Insert After
Insert At End

A click on each of these menus will bring up the same list of actions. They are

Item 1
Item 2
Item 3
Item 4


If I click on "Insert Before"->"Item 1" I would like to know that "Insert Before" was the QMenu that activated "item 1".

Will I have to create 12 actions to do this or is there a way to do it with just 4 actions?

amleto
7th October 2012, 00:26
You require different actions. Why do you think you should not create different QActions?

You could probably do it using qobject.html#sender, but I wouldn't advise it.