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!
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.Qt Code:
{ if (index.isValid()) { // ... } }To copy to clipboard, switch view to plain text mode
J-P Nurmi
nategoofs (14th August 2007)
Bookmarks