how get filtered data from QSortFilterProxyModel ?
-
wrote on 31 Jul 2021, 13:39 last edited by
hi guys
i just have a QAbstractItemModel and i filter data according to QSortFilterProxyModel
what i want is so simple , i just want to separate and loop over filtered data but i have no idea for that .
any help will be appreciated
thanks -
hi guys
i just have a QAbstractItemModel and i filter data according to QSortFilterProxyModel
what i want is so simple , i just want to separate and loop over filtered data but i have no idea for that .
any help will be appreciated
thankswrote on 31 Jul 2021, 14:04 last edited by JonB@paghsa said in how get filtered data from QSortFilterProxyModel ?:
and i filter data according to QSortFilterProxyModel
If you have done this you already have what you ask for? Just iterate/access via the
QSortFilterProxyModel
, whatever filter you have put on it will mean it will only contain/return those filtered rows. For example, once you have set the filter to filter out some rows, compare whatQSortFilterProxyModel::rowCount()
returns versus the source model'sQAbstractItemModel::rowCount()
. -
@paghsa said in how get filtered data from QSortFilterProxyModel ?:
and i filter data according to QSortFilterProxyModel
If you have done this you already have what you ask for? Just iterate/access via the
QSortFilterProxyModel
, whatever filter you have put on it will mean it will only contain/return those filtered rows. For example, once you have set the filter to filter out some rows, compare whatQSortFilterProxyModel::rowCount()
returns versus the source model'sQAbstractItemModel::rowCount()
.wrote on 31 Jul 2021, 14:31 last edited by paghsa 8 Jan 2021, 04:49@JonB
oh god it was dead simple
anyways thanks a lot ;)
for other people who may face to this problem you should use proxy->index() and play with itQModelIndex index = proxyModel->index(row , column , parentIndex); int rowCount = proxy->rowCount(proxyModel); // it gives you the count of rows qInfo() << proxy->data(index , sourceModel::enum); // it prints the corresponding data
in my case i have a treeModel and have to search all filtered rows for particular value.
-
@paghsa said in how get filtered data from QSortFilterProxyModel ?:
and i filter data according to QSortFilterProxyModel
If you have done this you already have what you ask for? Just iterate/access via the
QSortFilterProxyModel
, whatever filter you have put on it will mean it will only contain/return those filtered rows. For example, once you have set the filter to filter out some rows, compare whatQSortFilterProxyModel::rowCount()
returns versus the source model'sQAbstractItemModel::rowCount()
.wrote on 31 Jul 2021, 15:52 last edited byThis post is deleted!
1/4