QSortFilterProxyModel -filterAcceptsRow()- filter parent Node and child Node
-
wrote on 13 Dec 2011, 14:09 last edited by
Sounds like you forgot to add the .h file to your HEADERS section in your .pro file, and the .cpp file to the SOURCES section?
-
wrote on 20 Feb 2012, 15:50 last edited by
What does _parent type in this string?
@bool filterAcceptsRow(int source_row, const QModelIndex &source;_parent) const;@
And wath does this argument do?
And second question:
source_parent is source->parent()?
And in advance sorry for stupid questions) -
wrote on 20 Feb 2012, 16:03 last edited by
There was an unfortunate bug at the time in DevNet, that sometimes inserted ; at the wrong places in code sections. The code listing I posted suffered from this. The argument is supposed to be a single argument source_parent. I'll try to fixup the original posting. Thanks for noticing.
-
wrote on 20 Feb 2012, 17:27 last edited by
It is clear.
One more thank you for your help! -
wrote on 1 May 2012, 19:05 last edited by
Thank you - this thread has been really helpful!
-
wrote on 17 Dec 2014, 12:03 last edited by
Esta implementación recorre todo los sub-Nodos del padre buscando que el filterRegExp coincida con el Qt::DisplayRole del sub-Nodo.
El algoritmo no utiliza recursividad :D
@bool SortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
QList<QModelIndex> children;
children << sourceModel()->index(source_row, 0, source_parent);bool show = false; for(int i = 0; i < children.length(); i++) { if(show) break; // Add sub Nodos // for(int c = 0; c < sourceModel()->rowCount(children[i]) ;c++) children.append(children[i].child(c,0)); QString type = sourceModel()->data(children[i], Qt::DisplayRole).toString(); show = type.contains(filterRegExp()); } return show;
}@
-
wrote on 17 Dec 2014, 12:05 last edited by
Could you keep posts to English in this forum please? There are specialized sub-forums for other languages.
-
wrote on 17 Dec 2014, 12:05 last edited by
Could you keep posts to English in this forum please? There are specialized sub-forums for other languages.
-
-