[Qt-interest] QTableView: How can I get the data of selected row.
Mildred Ki'Lya
ml.mildred593 at gmail.com
Fri May 15 04:16:48 CEST 2009
On 05/12/2009 09:14 PM, Mhayk Whandson wrote:
> Hi all, I am tryng to get the datas of a one selected row. I would
> like to get all columns about this selected row. Example:
>
> ____ _________________ __________
> | ID | Name | Age |
> ---- ----------------- ----------
> | 1 | Mhayk Whandson | 22 |
> ---- ----------------- ----------
>
> So, I would like get all datas in these row(id, name, age). Could you help me ?
>
>
Well, I don't really understand what you're trying to do.
If you want to get all the data from a row, just do something like
QModelIndex idx = ... ;
int nbcols = idx->model()->columnCount();
for(int i = 0; i < nbcols; ++i) {
QModelIndex idx2 = idx->model()->index(idx->row(), i);
QVariant cell = idx->model()->data(idx2, role);
// do something with the QVariant
}
--
Mildred Ki'Lya
╭───────── mildred593@online.fr ──────────
│ Jabber, GoogleTalk:<mildred at jabber.fr>
│ Website:<http://ki.lya.online.fr> GPG ID: 9A7D 2E2B
│ Fingerprint: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 9A7D 2E2B
More information about the Qt-interest-old
mailing list