Results 1 to 4 of 4

Thread: connecting Pop up Menu List to actions/functions

  1. #1
    Join Date
    Jun 2013
    Posts
    58
    Thanks
    26
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Question connecting Pop up Menu List to actions/functions

    Thanks.... Solved
    Last edited by ebsaith; 18th June 2013 at 11:08. Reason: updated contents

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: connecting Pop up Menu List to actions/functions

    QAction has a triggered() signal which is emitted when the user activates the menu entry representing the action

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    ebsaith (18th June 2013)

  4. #3
    Join Date
    Jun 2013
    Posts
    58
    Thanks
    26
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: connecting Pop up Menu List to actions/functions

    This is what I have
    Qt Code:
    1. void MainWindow::slPopUpMenu()
    2. {
    3. QMenu *newMenu = new QMenu(this);
    4. newMenu->addAction(new QAction("Do that", this));
    5. }
    To copy to clipboard, switch view to plain text mode 
    how do get to the slot of the created action
    after it is triggered

    Im not seeing it!

    I even tried creating a action on the form, then I was able to go to slot
    but that how do I add that action to my menu?

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: connecting Pop up Menu List to actions/functions

    Quote Originally Posted by ebsaith View Post
    This is what I have
    Qt Code:
    1. void MainWindow::slPopUpMenu()
    2. {
    3. QMenu *newMenu = new QMenu(this);
    4. newMenu->addAction(new QAction("Do that", this));
    5. }
    To copy to clipboard, switch view to plain text mode 
    how do get to the slot of the created action
    after it is triggered

    Im not seeing it!
    As I said, connect to the action's triggered() signal

    Qt Code:
    1. QAction *action = new QAction("Do that", this));
    2. connect(action, SIGNAL(triggered()), this, SlOT(doThatSlot()));
    3. newMenu->addAction(action);
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

Similar Threads

  1. Adding actions to a context menu
    By aarelovich in forum Qt Programming
    Replies: 4
    Last Post: 7th December 2011, 12:47
  2. Menu Actions
    By GrahamLabdon in forum Newbie
    Replies: 9
    Last Post: 16th June 2010, 00:41
  3. Replies: 2
    Last Post: 25th November 2009, 06:15
  4. Connecting custom class actions
    By Toshikazu in forum Qt Programming
    Replies: 3
    Last Post: 15th October 2009, 15:31
  5. Replies: 12
    Last Post: 14th August 2007, 17:54

Tags for this Thread

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.