Argghh...
Ok, that's a newbie section, I need to be more patient...
//...
// for QSqlQueryModel or subclasses:
if(!qmod) return false;
QSqlRecord rec
= qmod
->record
(curr.
row());
// you have data inside the "rec" object
// for generic models:
int cc = md->columnCount(curr.parent());
for(int i=0;i<cc;i++){
QVariant dat
= md
->data
(curr.
sibling(curr.
row(), i
));
// you have the data inside the 'dat' object //...
}
QTableView *tv;
//...
QAbstractItemModel *md = tv->model();
QModelIndex curr = tv->currentIndex();
// for QSqlQueryModel or subclasses:
QSqlQueryModel *qmod = qobject_cast<QSqlQueryModel*>(md);
if(!qmod) return false;
QSqlRecord rec = qmod->record(curr.row()); // you have data inside the "rec" object
// for generic models:
int cc = md->columnCount(curr.parent());
for(int i=0;i<cc;i++){
QVariant dat = md->data(curr.sibling(curr.row(), i)); // you have the data inside the 'dat' object
//...
}
To copy to clipboard, switch view to plain text mode
As you see in both cases the data is accessed through the model.
Bookmarks