Results 1 to 2 of 2

Thread: Getting QMenu of selected QAction

  1. #1
    Join Date
    May 2011
    Posts
    20
    Thanked 3 Times in 3 Posts
    Platforms
    Unix/X11

    Default Getting QMenu of selected QAction

    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?

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Getting QMenu of selected QAction

    You require different actions. Why do you think you should not create different QActions?

    You could probably do it using http://doc.qt.io/qt-4.8/qobject.html#sender, but I wouldn't advise it.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. QAction with QMenu click event
    By mero in forum Qt Programming
    Replies: 1
    Last Post: 15th July 2012, 11:49
  2. Can't disable a QAction in QMenu
    By punkypogo in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2010, 15:07
  3. how to add QMenu or QAction inside QDesigner
    By eric_vi in forum Qt Tools
    Replies: 1
    Last Post: 2nd August 2009, 17:48
  4. QAction text color (QMenu)
    By StefanK in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2009, 16:14
  5. QPushButton QMenu QAction
    By hgedek in forum Newbie
    Replies: 2
    Last Post: 1st November 2007, 13:29

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.