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
    Naveen

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    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, 19:10
  2. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03
  3. Creating events for combobox items
    By confused in forum Newbie
    Replies: 4
    Last Post: 26th March 2006, 16:40

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.