Skip to content Skip to sidebar Skip to footer

How To Get Qtableview Right Clicked Index

The code below creates a single dialog with a QTableView view. On left-click the onLeftClickfunction gets an QModelIndex index. This QModelIndex is used later to print the row and

Solution 1:

You have to use the indexAt() method of the QAbstractScrollArea (QTableView):

def onRightClick(self, qPoint):
    index = self.view.indexAt(qPoint)
    if index.isValid():
        print('onClick index.row: %s, index.col: %s' % (index.row(), index.column()))

Post a Comment for "How To Get Qtableview Right Clicked Index"