tags:

views:

1328

answers:

2
+2  A: 

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 );
Nick Presta
Your first one did work, second one not. It doesn't matter that it loses focus because I show a modal dialog. I'll mark this answer as correct if nobody is going to propose a more natural solution.
Georg
I just fired up an example to test out EditTriggers and it appears to work (C++, Qt 4.4.3). I can click on each cell and such but I cannot double click on them to edit or anything at all. I don't know why it doesn't work for you. *shrug*
Nick Presta
It's about closing the editor, not being not able to edit it. The next time one double clicks it should open the editor again.
Georg
A: 

You may be able to use QTableWidget.closePersistentEditor() to close the editor. However, QAbstractItemView.closeEditor() may be closer to what you want, especially since you seem to be comfortable with the QModelIndex-based API and are already using a custom editor widget.

David Boddie