JeanC
19th January 2008, 12:55
I want to act on the selected rows in a qtableview.
I'm trying the code below, however, list.count() gives the amount of selected cells in stead of selected rows, I only need the rowcount. How do I get that please, I searched but seems I'm too dumb to find it.
const QModelIndexList list = table->selectionModel()->selection().indexes();
for (int i = 0; i < list.count(); i++)
{
QModelIndex index = list.at(i);
int row = index.row();
QString name = model->record(row).value("name").toString();
qDebug() << i << row << name;
}
}
I'm trying the code below, however, list.count() gives the amount of selected cells in stead of selected rows, I only need the rowcount. How do I get that please, I searched but seems I'm too dumb to find it.
const QModelIndexList list = table->selectionModel()->selection().indexes();
for (int i = 0; i < list.count(); i++)
{
QModelIndex index = list.at(i);
int row = index.row();
QString name = model->record(row).value("name").toString();
qDebug() << i << row << name;
}
}