how to emit double click on cell Signal in QTableView from right click menu
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!!
Code:
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?
Re: how to emit double click on cell Signal in QTableView from right click menu
Call the edit() slot of the view with the respective model index.
Cheers,
_
Re: how to emit double click on cell Signal in QTableView from right click menu
Quote:
Originally Posted by
anda_skoa
Call the edit() slot of the view with the respective model index.
Cheers,
_
I don't know how to do that, can you give an example...
Added after 8 minutes:
Do you mean like this
Code:
self.connect(self, SIGNAL("edit()"), SLOT("renAction"))
Re: how to emit double click on cell Signal in QTableView from right click menu
Obviously the mention of "slot" got you confused, let me rephrase:
call the view's edit() method, i.e. this one: http://qt-project.org/doc/qt-4.8/qab...view.html#edit
Cheers,
_
Re: how to emit double click on cell Signal in QTableView from right click menu
thanks
Code:
elf.edit(self.selectionModel().currentIndex())