PDA

View Full Version : get all row data from a selected row



thefatladysingsopera
3rd May 2011, 13:00
I want to list tables in a database and i have the following columns.

id | table_name | date_created | table_size


I want to highlight the entire row and not a single cell.How can i get the all the data of a selected row,i.e the currently selected id,table_name,date_created,table_size.

Jonny174
3rd May 2011, 13:24
Try this:


int row = TreeView->currentIndex().row();

for (int i = 0; i < TreeView->model()->columnCount(); ++i)
QString fileName = TreeView->model()->data( TreeView->model()->index(row, i) ).toString();

MasterBLB
3rd May 2011, 13:35
First,select set selection behaviour of your view to QAbstractItemView::SelectRows
Second,the best way to obtain a whole row from QSqlTableModel it the record function;