PDA

View Full Version : Is there a signal in QTableWidget that “fires” when a cell has lost focus?



tstankey
8th September 2006, 16:19
I need to detect when a cell in my QTableWidget spreadsheet has lost focus so I can check to see if its value has changed.

jacek
8th September 2006, 16:36
Maybe this will help?

void QTableWidget::cellChanged ( int row, int column ) [signal]
This signal is emitted whenever the data of the item in the cell specidied by row and column has changed.
or this:

void QTableWidget::currentCellChanged ( int currentRow, int currentColumn, int previousRow, int previousColumn ) [signal]
This signal is emitted whenever the current cell changes. The cell specified by previousRow and previousColumn is the cell that previously had the focus, the cell specified by currentRow and currentColumn is the new current cell.

tstankey
8th September 2006, 18:50
Thanks for the quick reply.

I am already using the currentItemChanged signal and it works fine when I move from one cell to another cell in the QTableWidget. This signal isn't being sent, however, when I mouse-click outside the spreadsheet. In this case, the focus does indeed move off of the cell I was in, and the cell contasins a new value, but I'm not aware of it.

I ended up using the mouseReleaseEvent to detect this situation. I needed to store the QTableWidgetItem of the cell I was in the last time and this allowed me to detect the new value, after the fact.

jacek
8th September 2006, 18:54
In this case, the focus does indeed move off of the cell I was in, and the cell contasins a new value, but I'm not aware of it.
Then maybe cellChanged() will be better? There is also QFocusEvent, which you can catch using an event filter or by reimplementing focusOutEvent().