PDA

View Full Version : problem with getting info from tableView



tinysoft
19th August 2010, 12:46
hi ..
i want to get cell content from table view (ui->tableView)

how can i do that ??

Lykurg
19th August 2010, 13:52
how can i do that ??Not by posting twice;)
Get the index of the cell (e.g. QAbstractItemView::currentIndex()) and then use the data function to receive the content. (see QModelIndex::data())

tinysoft
19th August 2010, 14:14
Not by posting twice;)


sorry about that .. :) problem with the browser caused it .

one more question : how can i use ( QVariant QModelIndex::data ( int role = Qt::DisplayRole ) const ) if i want to get item (1,1) for example ??

Lykurg
19th August 2010, 14:20
You just have to combine the two functions:
QAbstractItemModel *model = ui->tableView->model(); // if you don't have a class wide pointer to your model;
if (!model)
return;
QModelIndex index = model->index(1,1);
if(!index.isValid)
return;
qDebug() << index.data().toString();

tinysoft
19th August 2010, 14:28
great thanks !