PDA

View Full Version : How to extract thr list of actions associated with an Action having popup menu



siva prasanna
25th November 2009, 06:50
Hello all,
I have an Action..it has popup menu associated. I want to extract list of actions in that popup menu. I tried like this :

Let " action " has popup menu.
QMenu *menu = action->menu();
QList<QAction *> list = menu->actions();

But the problem is ... list.count() is returning ZERO ( 0 ) although action has popup menu.

Can you help me...
Thank you in advance.

yogeshgokul
25th November 2009, 07:07
Hello all,
I have an Action..it has popup menu associated. I want to extract list of actions in that popup menu. I tried like this :

Let " action " has popup menu.
QMenu *menu = action->menu();
QList<QAction *> list = menu->actions();

But the problem is ... list.count() is returning ZERO ( 0 ) although action has popup menu.

The Qt docs says, that returned list could be empty.

QList<QAction *> QWidget::actions () const

Returns the (possibly empty) list of this widget's actions.

siva prasanna
25th November 2009, 07:15
So I have to create one Widget and I have to setMenu for that widget.
then I have to extract the actions() right?

QMenu *menu = actions->menu();
QToolButton *tool = new QToolButton;
tool->setMenu(menu);
QList<QAction *> list = tool->actions();


is this correct way . . .. ??