PDA

View Full Version : What is the difference between selectionChanged & currentChanged?



IndikaU
26th September 2011, 15:01
Hi,

I'm using a a QTableView to show data of QStandardItem model. For each individual cell change I'm going to update a custom data structure. However to detect the current cell change I need a signal to catch.

I found QItemSelectionModel::currentChanged & QItemSelectionModel::selectionChanged in the documentation. Anyway I'm bit confused with these two. Can anyone please explain the different ( despite of the signatures ) purposes of these two?

Thank you,
Indika...

saimel
26th September 2011, 22:27
The difference consists in the data type of the parameters of the signals, QItemSelectionModel::currentChanged receive two parameters, boths are QModelIndex data type and QItemSelectionModel::selectionChanged receive two parameters too, but this are QItemSelection data type, so in dependence of you want to do with this values you have to decide which signal to catch.

ChrisW67
26th September 2011, 23:18
The current cell is the one that you would edit if you started typing (or pressed F2)... it is a single cell and not necessarily related to the selection. On screen it typically has a faint box border.

The selection is a set of highlighted cells that would typically be the target of a copy/paste/drag type action. The selection can be empty, a single cell, whole rows/columns, contiguous or disjoint collections of cells depending on options. On screen the selection is typically rendered as white text on a dark background instead of black on white like unselected cells.