PDA

View Full Version : get current item from QCompleter



evgenM
13th August 2007, 13:07
i have QCompleter and when i start completion i need to get current(first) item from popup list.

some code :


//CompleterModel == QStandardItemModel
//mComplet is QCompleter
//
showCompleter();
if (mComplet->popup()->isVisible())
{
QModelIndex index = mComplet->popup()->currentIndex();
if (index.isValid())
{
CompleterModel* model = (CompleterModel*)mComplet->model();
if (model)
{
QStandardItem* item = model->itemFromIndex(index);
if (item)
cout <<"item OK"<<endl;
else
cout <<"item Error"<<endl;
}
}

so this function return "item Error" -- what's wrong?? (i think problem from completer sorting, but how to get proxy model?

jpn
15th August 2007, 18:16
Yes, the problem must be that view returns an index of the proxy model, indeed. Perhaps you could try a hackish way of using mComplet->findChild<QAbstractProxyModel*>() and then QAbstractProxyModel::mapToSource().