How would I add a rightClick function to a QTableView with a subclassed QAbstractTableModel? Currently, I have (and would like to replace) a Q3Table with Q3Popupmenu connected through a mousepressed signal from Q3Table.
Thanks!
Printable View
How would I add a rightClick function to a QTableView with a subclassed QAbstractTableModel? Currently, I have (and would like to replace) a Q3Table with Q3Popupmenu connected through a mousepressed signal from Q3Table.
Thanks!
Reimplement QWidget::contextMenuEvent(). You can get the item (if any) at requested position with QContextMenuEvent::pos() and QAbstractItemView::indexAt(), more or less like:
There are also alternative ways of handling context menu. See QWidget::contextMenuPolicy for more details.Code:
{ if (index.isValid()) { // ... } }