View Full Version : get current item from QCompleter

13th August 2007, 14: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
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;
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?

15th August 2007, 19: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().