Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating popup menu in Qt for QTableView

Tags:

c++

qt

qtableview

I have a QTableView in the main UI of my program. I'd like to show popup menu when user right clicks on the cells of the table and take appropriate action when an option is selected from the menu.

I am using Qt Creator 1 (Qt version 4.5). How can I do that?

like image 865
Donotalo Avatar asked Apr 12 '09 07:04

Donotalo


1 Answers

Check out the customContextMenuRequested signal to get the event, and use a QMenu for the menu itself. Use QTableView::indexAt to find out what, if any, cell was clicked based on the coordinates given to the signal and take the appropriate action when a menu item is clicked.

like image 111
Simon Broadhead Avatar answered Sep 18 '22 13:09

Simon Broadhead