<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
Hi,<br>
Filtering is done by overriding the filterAcceptsRow() method: <a href="https://doc.qt.io/qt-5/qsortfilterproxymodel.html#filterAcceptsRow" id="LPNoLP925614">
https://doc.qt.io/qt-5/qsortfilterproxymodel.html#filterAcceptsRow</a><br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>De :</b> Devel <devel-bounces@lists.sailfishos.org> de la part de Oleg Linkin <maledictusdemagog@gmail.com><br>
<b>Envoyé :</b> vendredi 16 mars 2018 06:56<br>
<b>À :</b> devel@lists.sailfishos.org<br>
<b>Objet :</b> [SailfishDevel] Show limited items in listview</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hello.<br>
I want to show only limited count of items from in ListView.<br>
I create QSortFilterProxyModel subclass and reimplement rowCount method. But <br>
this doesn't work. <br>
If I return some number from rowCount - view doesn't show anything. If I <br>
return QSortFilterProxyModel::rowCount(parent) - ListView show all elements <br>
from model.<br>
<br>
// Show all(7) elements from source model<br>
int LimitProxyModel::rowCount(const QModelIndex& parent) const<br>
{<br>
    return QSortFilterProxyModel(parent);<br>
}<br>
<br>
// Show all(7) elements from source model<br>
int LimitProxyModel::rowCount(const QModelIndex& parent) const<br>
{<br>
    int count = sourceModel()->rowCount(parent);<br>
    return count;<br>
}<br>
<br>
// Show nothing<br>
int LimitProxyModel::rowCount(const QModelIndex& parent) const<br>
{<br>
    int count = sourceModel()->rowCount(parent);<br>
    return 7;<br>
}<br>
<br>
// Show nothing<br>
int LimitProxyModel::rowCount(const QModelIndex& parent) const<br>
{<br>
    return 7;<br>
}<br>
<br>
Have you any ideas?<br>
Thank you<br>
<br>
<br>
_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to devel-unsubscribe@lists.sailfishos.org</div>
</span></font></div>
</body>
</html>