PDA

View Full Version : Getting the selected row



k12yp70n
21st May 2009, 14:59
Hi there folks!

I know that to remove a given record from a model, I would need to provide the record to remove. The problem is that the record to be removed is one selected by the user in a table view (obviously linked to the model).

How would I obtain an integer for the row number, that can be used in the following way:


model->removeRows(int row, int count)

As usual sample code and an explanation would be very much appreciated.

Thanks in advance,
:D

k12yp70n
25th May 2009, 12:20
BUMP please

jpn
25th May 2009, 12:22
See QAbstractItemView::currentIndex() and QAbstractItemView::selectionModel().

QAmazigh
30th May 2009, 01:07
QTableView gives you the selected row(s) :



QModelIndexList list = view->selectionModel()->selectedRows();
int row = list.at(i).row();// i = integer to browse list

freezeblue
4th June 2009, 16:01
And... there is a signal to notify you the cell just selected by user:


void QAbstractItemView::activated( const QModelIndex & index )