Results 1 to 2 of 2

Thread: MousePress Events on ContextMenu items

  1. #1

    Question MousePress Events on ContextMenu items

    I have a CustomContext menu and have added items to that like this

    QAction* act = menu.addAction("Restore");

    QAction* act2 = menu.addAction("Close");

    I want to implement MousePressEvent for this CustomContextMenu and give the corresponding functionality to their press.....

    like if Close is pressed i want to execute exit() method.....on this click...

    How can I capture these mousePress event on a CustomContextMenu items

    Thanks in Advance

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: MousePress Events on ContextMenu items

    It's not how it's done. You should connect their activated() or triggered() signal to a slot which implements the functionality. For example:

    Qt Code:
    1. connect(act2, SIGNAL(triggered()), this, SLOT(close()));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Can Qt4 capture mousePress events on the desktop?
    By simula in forum Qt Programming
    Replies: 5
    Last Post: 6th January 2009, 20:10
  2. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 16:03
  3. Creating events for combobox items
    By confused in forum Newbie
    Replies: 4
    Last Post: 26th March 2006, 17:40


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.