Results 1 to 5 of 5

Thread: Open a pop up menu when right click on any cell of the table

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Aug 2006
    Posts
    77
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    14
    Thanked 3 Times in 3 Posts

    Default Re: Open a pop up menu when right click on any cell of the table

    QTableWidgetItem * itemAt ( const QPoint & point ) const


    Qt Code:
    1. void MyTableWidget::contextMenuEvent( QContextMenuEvent * e )
    2. {
    3. QAction *pAddAction = new QAction("Add",this);
    4. connect(pAddAction,SIGNAL(triggered()),this,(slotAdd()));
    5. QAction *pRemoveAction = new QAction("Remove",this);
    6. connect(pRemoveAction ,SIGNAL(triggered()),this,(slotRemove()));
    7. QAction *pUpdateAction = new QAction("Update",this);
    8. connect(pUpdateAction ,SIGNAL(triggered()),this,(slotUpdate()));
    9. //
    10. QMenu *pContextMenu = new QMenu( this);
    11. pContextMenu->addAction(pAddAction);
    12. pContextMenu->addAction(pRemoveAction );
    13. pContextMenu->addAction(pUpdateAction );
    14. //
    15. pContextMenu->exec( e->globalPos() );
    16.  
    17. delete pContextMenu;
    18. pContextMenu = NULL;
    19. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to kemp for this useful post:

    katta_ashish (9th September 2010)

Similar Threads

  1. Replies: 0
    Last Post: 29th July 2009, 19:13
  2. QTreeView cell as table
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2009, 09:45
  3. Making Table cell as a combobox?
    By kaushal_gaurav in forum Qt Programming
    Replies: 9
    Last Post: 1st August 2008, 12:04
  4. Replies: 4
    Last Post: 4th February 2008, 06:16
  5. Highlighting the border of cell in Table
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 21st March 2006, 08:20

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
  •  
Qt is a trademark of The Qt Company.