waynew
14th February 2010, 01:05
I need to relate the view index to the model index for searches in the view.
Based the model index on the database table primary key.
Not sure I understand the proxy model doc, but,
here is what I tried:
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(model);
QModelIndex midx = model->index(id, 0, QModelIndex());
qDebug() << " midx is " << midx;
QModelIndex vidx = proxy->mapFromSource(midx);
qDebug() << " vidx is " << vidx;
midx has the correct value for the row in the model/database.
vidx is -1 The error says index from wrong model passed to mapFromSource.
What's wrong?
Based the model index on the database table primary key.
Not sure I understand the proxy model doc, but,
here is what I tried:
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(model);
QModelIndex midx = model->index(id, 0, QModelIndex());
qDebug() << " midx is " << midx;
QModelIndex vidx = proxy->mapFromSource(midx);
qDebug() << " vidx is " << vidx;
midx has the correct value for the row in the model/database.
vidx is -1 The error says index from wrong model passed to mapFromSource.
What's wrong?