Results 1 to 3 of 3

Thread: How to extract thr list of actions associated with an Action having popup menu

  1. #1
    Join Date
    Oct 2009
    Location
    Bangalore
    Posts
    3
    Thanks
    1
    Qt products
    Qt4

    Default How to extract thr list of actions associated with an Action having popup menu

    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.

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to extract thr list of actions associated with an Action having popup menu

    Quote Originally Posted by siva prasanna View Post
    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.

  3. #3
    Join Date
    Oct 2009
    Location
    Bangalore
    Posts
    3
    Thanks
    1
    Qt products
    Qt4

    Default Re: How to extract thr list of actions associated with an Action having popup menu

    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 . . .. ??

Similar Threads

  1. Replies: 12
    Last Post: 21st November 2008, 05:42
  2. ListView Dynamic Popup menu
    By raphaelf in forum Newbie
    Replies: 3
    Last Post: 14th October 2006, 20:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.