[Qt-interest] QTableView::indexAt(QPoint) problem
Stephen Collyer
scollyer at netspinner.co.uk
Thu May 28 17:01:19 CEST 2009
I'm trying to access the data in a QTableView via indexAt() with code
as below:
QModelIndex model_index =
projects_table_view_->table_view->selectionModel()->currentIndex();
if (! model_index.isValid() || model_index.column() != 0)
{
return;
}
QPoint point(model_index.row(), 2);
std::cout << point.rx() << ", " << point.ry() << std::endl;
QModelIndex oindex = projects_table_view_->table_view->indexAt(point);
std::cout << "valid: " << (oindex.isValid() ? "yes" : "no") <<
std::endl;
std::cout << "data: " << qPrintable(oindex.data().toString()) <<
std::endl;
Regardless of the coords that I supply to the QPoint ctor, oindex.data()
returns the same data, which seems to be that with coords (0,0).
All of the model indices are valid, however.
Can anyone see what is going on here ?
I'm using Qt 4.5.0.
--
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090528/3d082340/attachment.html
More information about the Qt-interest-old
mailing list