[SailfishDevel] Show limited items in listview

Sylvain B. sthocs at hotmail.com
Mon Mar 19 13:55:49 UTC 2018


Hi,
Filtering is done by overriding the filterAcceptsRow() method: https://doc.qt.io/qt-5/qsortfilterproxymodel.html#filterAcceptsRow
________________________________
De : Devel <devel-bounces at lists.sailfishos.org> de la part de Oleg Linkin <maledictusdemagog at gmail.com>
Envoyé : vendredi 16 mars 2018 06:56
À : devel at lists.sailfishos.org
Objet : [SailfishDevel] Show limited items in listview

Hello.
I want to show only limited count of items from in ListView.
I create QSortFilterProxyModel subclass and reimplement rowCount method. But
this doesn't work.
If I return some number from rowCount - view doesn't show anything. If I
return QSortFilterProxyModel::rowCount(parent) - ListView show all elements
from model.

// Show all(7) elements from source model
int LimitProxyModel::rowCount(const QModelIndex& parent) const
{
    return QSortFilterProxyModel(parent);
}

// Show all(7) elements from source model
int LimitProxyModel::rowCount(const QModelIndex& parent) const
{
    int count = sourceModel()->rowCount(parent);
    return count;
}

// Show nothing
int LimitProxyModel::rowCount(const QModelIndex& parent) const
{
    int count = sourceModel()->rowCount(parent);
    return 7;
}

// Show nothing
int LimitProxyModel::rowCount(const QModelIndex& parent) const
{
    return 7;
}

Have you any ideas?
Thank you


_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20180319/072d0472/attachment.html>


More information about the Devel mailing list