PDA

View Full Version : QAbstractItemView activated



Shaitan
10th July 2007, 12:06
Hi all,

I have a QTableView which can be edited by the user, but there is an index column that can´t have duplicated cells (each row has an unique ID).
For this, i check the contents of the edited cell and search in the index column for it.
The problem is that if i find duplicates, i want to revert to the previous data in that cell.
I´ve been trying to write a QString with the cell gets active with its contents, (signal activated), but it never throws this signal... Is there other way to know when a cell gets selected??? (something like a signal for knowing when a cell gets focused)


Thx!!!

jpn
10th July 2007, 12:11
Perhaps you could do the validation in QAbstractItemDelegate::setModelData() or QAbstractItemModel::setData()?

Shaitan
10th July 2007, 14:01
The validation works well, the problem is getting the old value back if the inserted one is not valid... previously I inserted a blank String with 'insertData', but i want to insert the old data back....

J.

jpn
10th July 2007, 14:48
By doing the validation in setModelData() or setData() you could prevent invalid data from reaching the model. The previous value would remain after an editor gets closed and attempts to set invalid data.

Shaitan
10th July 2007, 15:51
The prob. is that i dont use setData by code. The TableView is editable, so the model autoupdates (or i think so).
Perhaps there is a signal (something like onCellFocused) that could give me a chance to store the content of the cell in other variable....
I dont know if im clear enough (perhaps just too noob)

J.

jpn
10th July 2007, 16:37
The prob. is that i dont use setData by code. The TableView is editable, so the model autoupdates (or i think so).
The data gets set to the model via aforementioned methods by the underlying model-view framework.