PDA

View Full Version : Extract specific column data using row index - QTableView



johnnyturbo3
3rd September 2010, 10:05
Hi,

I want to be able to extract a specific column's data using a row index. For example, my table is populated using an SQL query, when a user selects an item from the table the whole row is highlighted. From this highlighted row, I want to extract the 2nd column row as a String value.

I have the following code/slot for when the table is selected:

void GUI::receviedIndex( const QModelIndex &index ){

QString temp = QString::number(index.row());
QMessageBox::critical(0, QObject::tr("Testing"),temp);
}


I've tried a couple of things without success. Can anyone suggest what classes/methods to look at in order to achieve this?

Thanks

waynew
5th September 2010, 15:03
Are you trying to get the row, the column, or the cell data? It's not clear to me.

Lykurg
5th September 2010, 15:06
See QModelIndex::sibling() and QModelIndex::data().