Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell a QTableWidget to end editing a cell?

Tags:

qt

pyqt

I'm showing a popup menu to select some values in a QTableWidget. The lowest item is a "Modify list" entry, when I select it a new window should automatically appear and the QComboBox should vanish and the cell return to a Qt::DisplayRole state.

Now Qt has all those nice API-calls like QTableWidget.edit() and QTableWidget.editItem(), what I'm really looking for is a QTableWidget.endEditing(), preferably without specifying the index of the cell, though I could get that using this call:

table.currentIndex()

… but I don't know if I can guarantee that the current cell is the cell being edited at all times.

Is there an API to close those kind of editors?

Popup menu

like image 696
Georg Schölly Avatar asked Feb 05 '09 23:02

Georg Schölly


1 Answers

QTableWidget inherits 19 public slots from QWidget. One of those is setDisabled(), which should disable input events for that widget and all of its children.

I would try:

table.setDisabled( true );
table.setDisabled( false );

Although you said it does not work for you, there is an alternative method: If you don't like that (the table loses focus, I believe), you can try using EditTriggers. For example:

table.setEditTriggers( QAbstractItemView::NoEditTriggers );
like image 76
Nick Presta Avatar answered Sep 28 '22 15:09

Nick Presta