<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QWidget iterator]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I'm working on my project to update code written in 2001.  I'm having trouble with a function that uses a QListViewItemIterator:</p>
<pre><code>////////////////////////////////////
//// Write each channel to file  ///
////////////////////////////////////
bool BookmarkData::WriteCycle()
{
  BookmarkItem *bm;
  bookmark_t data;
  QListViewItemIterator it ( bmList );  //&lt;- error: unknown type name "QListViewItemIterator"

  // iterate through all items in the list
  for( ; it.current(); ++it){

     bm = (BookmarkItem *)it.current();

     bm-&gt;getBookmark( &amp;data );
     
     // add number of child in case of folder
     if(bm-&gt;isFolderBegin()){
        data.freq = bm-&gt;childCount();
     }

     WriteEntry( &amp;data );

  }

  return true;
}
</code></pre>
<p dir="auto">BookmarkItem was a QListViewItem and I changed to QListWidgetItem.<br />
bmList is a QListView*.</p>
<p dir="auto">I'm not quite sure how to accomplish the same functionality as the original code.  I haven't used iterators and would appreciate some advice on how to get this working in modern Qt.</p>
]]></description><link>https://forum.qt.io/topic/139155/qwidget-iterator</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 05:47:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139155.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Sep 2022 20:45:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QWidget iterator on Thu, 08 Sep 2022 14:50:02 GMT]]></title><description><![CDATA[<p dir="auto">QListWidgetItem is an item type of QListWidget. QListWidget is a convenience class that combines a view and a model</p>
<p dir="auto">Since <code>bmList</code> is a QListView you can't use QListWidgetItem with it. QListView is a view class. There is no way to get an item because there are no items in it. It operates only on an abstract model. You can call <code>model()</code> to get it. It is of type <code>QAbstractItemModel</code>. From it you can get <a href="https://doc.qt.io/qt-6/qabstractitemmodel.html#rowCount" target="_blank" rel="noopener noreferrer nofollow ugc">rowCount()</a>, then in a loop get <a href="https://doc.qt.io/qt-6/qabstractitemmodel.html#index" target="_blank" rel="noopener noreferrer nofollow ugc">index()</a> for each row and for that index you can read <a href="https://doc.qt.io/qt-6/qabstractitemmodel.html#data" target="_blank" rel="noopener noreferrer nofollow ugc">data()</a>.</p>
]]></description><link>https://forum.qt.io/post/727932</link><guid isPermaLink="true">https://forum.qt.io/post/727932</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Thu, 08 Sep 2022 14:50:02 GMT</pubDate></item><item><title><![CDATA[Reply to QWidget iterator on Thu, 08 Sep 2022 14:10:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mscottm">@<bdi>MScottM</bdi></a> Did you read the documentation I gave you? itemAt is a method in QListWidget class...<br />
Also, it takes two parameters.</p>
]]></description><link>https://forum.qt.io/post/727931</link><guid isPermaLink="true">https://forum.qt.io/post/727931</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 08 Sep 2022 14:10:10 GMT</pubDate></item><item><title><![CDATA[Reply to QWidget iterator on Thu, 08 Sep 2022 14:08:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> Qt is telling me: 'No member named 'itemAt in QListWidgetItem' - what am I doing wrong?</p>
<pre><code>QListWidgetItem* it;
</code></pre>
<p dir="auto">then,</p>
<pre><code>it-&gt;itemAt(x) // No member...
</code></pre>
]]></description><link>https://forum.qt.io/post/727930</link><guid isPermaLink="true">https://forum.qt.io/post/727930</guid><dc:creator><![CDATA[MScottM]]></dc:creator><pubDate>Thu, 08 Sep 2022 14:08:20 GMT</pubDate></item><item><title><![CDATA[Reply to QWidget iterator on Thu, 08 Sep 2022 06:23:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mscottm">@<bdi>MScottM</bdi></a> You can iterate ovet items in QListWidget using <a href="https://doc.qt.io/qt-6/qlistwidget.html#itemAt-1" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qlistwidget.html#itemAt-1</a></p>
]]></description><link>https://forum.qt.io/post/727857</link><guid isPermaLink="true">https://forum.qt.io/post/727857</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 08 Sep 2022 06:23:58 GMT</pubDate></item></channel></rss>