Note that there are some explanatory texts on larger screens.

plurals
  1. POQML ListView count is zero and only some rows are visible
    primarykey
    data
    text
    <p>I have created a ListView model based on QAbstractListModel similar to this <a href="http://doc.qt.digia.com/4.7-snapshot/declarative-modelviews-abstractitemmodel.html" rel="nofollow">example</a>. The problem is my ListView doesn't show all rows, but only those which are initialy visible. So when I scroll (or flick) down theres only black space. ListView has count == 0 but it should have count == 10, since I've added 10 elements.</p> <p>My class contains the necessary mothods to update the model rowCount</p> <pre><code>// needed as implementation of virtual method int rowCount(const QModelIndex &amp; parent) const { return standings.size(); } int rowCount() { return standings.size(); } void addStanding(const Standing &amp;st) { beginInsertRows(QModelIndex(), rowCount(), rowCount()); qDebug() &lt;&lt; "row cnt: " &lt;&lt; rowCount(); standings &lt;&lt; st; endInsertRows(); } </code></pre> <p>I also update the ListView model</p> <pre><code>rootContext = (QDeclarativeContext*)(viewer-&gt;rootContext()); rootContext-&gt;setContextProperty("myModel", &amp;sm); </code></pre> <p>QML code</p> <pre><code>ListView { id: raceList objectName: "standingList" y: header.height width: parent.width height: parent.height - header.height clip: true model: myModel delegate: rowComp } Component { id: rowComp SessionRowDelegate { } } </code></pre> <p>I would also like to mention that this works fine with a static model. <strong>How to make ListView display all items all the time and not only if visible to user?</strong></p> <p>SessionRowDelegate</p> <pre><code>Rectangle { id: rowbg width: parent.width height: 34 * (1 + (parent.width - 360) * 0.002) // contains other elements with height not exceeding rowbg's height // ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload