[Solved]Subclassing QAbstractProxyModel issue
-
Hi guys,
I'm trying to subclass QAbstractProxyModel in order to implement my own search engine on a data set.
I had to implement these functions:
@
QModelIndex proxymodel::mapFromSource(const QModelIndex &sourceIndex) const
{
return QModelIndex();
}QModelIndex proxymodel::mapToSource(const QModelIndex &proxyIndex) const
{
if(proxyIndex.isValid())
return createIndex(resultado.results().at(proxyIndex.row()).x,buscacoluna);
else
return QModelIndex();
}QModelIndex proxymodel::parent(const QModelIndex &child) const
{
return QModelIndex();
}QModelIndex proxymodel::index(int row, int column, const QModelIndex &parent) const
{
return createIndex(row,column);
}int proxymodel::rowCount(const QModelIndex &parent) const
{
return resultado.results().count();
}int proxymodel::columnCount(const QModelIndex &parent) const
{
return 1;
}QVariant proxymodel::data(const QModelIndex &proxyIndex, int role) const
{
return resultado.results().at(proxyIndex.row()).dados;
}Qt::ItemFlags proxymodel::flags(const QModelIndex &index) const
{
return (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
}
@I'm sure my data function returns a valid QVariant, but my QListView doesn't show any record.
Does anyone could help me to fix this?
Thanks.