Creating a popup menu in Qt for QTableView

I have a QTableView in the main interface of my program. I would like to show a pop-up menu when the user right-clicks on the cells in the table and takes appropriate action when an option is selected in the menu.

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

+7
c ++ qt qtableview
source share
1 answer

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

+22
source share

All Articles