In my QTableView I have a model MyDataModel that inherits from QAbstractTableModel to which I have added the below method to be able to rename the item by double clicking it!!
def flags(self, index):
""" This method sets the text in the cell editor selected
and editable and enabled.
"""
return QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable
def flags(self, index):
""" This method sets the text in the cell editor selected
and editable and enabled.
"""
return QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable
To copy to clipboard, switch view to plain text mode
But now I have also added a right click contextual menu on which i have added the rename option, so I want to trigger the double click behavior to rename the selected item the same way I did by double clicking it.
How can I achieve that?
Bookmarks