(Qt 4.1.4)

I've created a standard QTableWidget in a GUI, and I'm using a reimplementation of QItemDelegate so I can provide my own custom mechanism to edit the data contained within that QTableWidget. I'm using QDoubleSpinBox and QComboBox as my custom editing widgets. This all works happily, but my problems stem from defining how the editing is triggered.

What I want to happen is to be able to navigate between the cells (using direction arrows), and kick-off a cell edit by pressing any key, 'Return' or 'Space' keys.


If I set up the following edit trigger flags on the QTableWidget as follows:

Qt Code:
  1. QAbstractItemView::DoubleClicked |
  2. QAbstractItemView::SelectedClicked |
  3. QAbstractItemView::EditKeyPressed |
  4. QAbstractItemView::AnyKeyPressed
To copy to clipboard, switch view to plain text mode 

The behaviour I get is that whenever you enter text, (EG: '1', 'g', 'Z' etc..), the edit is triggered, but editing is NOT triggered on a 'return' or 'space' key stroke.

Alternatively, if I set the edit trigger flags as follows:

Qt Code:
  1. QAbstractItemView::AllEditTriggers
To copy to clipboard, switch view to plain text mode 

I now acheived the desired result of having the edit triggered by a 'space' or 'return', but I also have the undesired result of having any movement onto a new cell triggering an edit. This is a problem because the spin and combo boxes take control of the up and down key strokes; essentially meaning that you can't swiftly or easily navigate the QTableWidget without cancelling the edit (either by 'return' or 'enter').


So, in essence my problem seems to be that I can either have 'Space' and 'Return' start an edit, OR I can have navigation between cells without automatically starting an edit, but not both (which is what I'm looking for!)


While it's possible to hook in to the key press event (either by superclassing QTableWidget, or by installing an event filter), I was wondering if there was a simple way of acheiving the desired behaviour, whether I've done, or missed something rather silly!

Thanks!

-Martin