krystosan
6th January 2014, 17:28
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
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?
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
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?