<?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[Resizing QList for Qt5]]></title><description><![CDATA[<p dir="auto">Hi. I'm on Qt 5.15. I'm trying to create a QList of ints and fill them with 0s. I wanted to use resize() but it doesn't seem to be available for Qt5. Is there a workaround or do I have to manually append the list by quite a few times?</p>
]]></description><link>https://forum.qt.io/topic/140204/resizing-qlist-for-qt5</link><generator>RSS for Node</generator><lastBuildDate>Fri, 19 Jun 2026 00:14:08 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/140204.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Oct 2022 12:25:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Resizing QList for Qt5 on Thu, 20 Oct 2022 12:46:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a>  reserve does not resize the list :(</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dummie1138">@<bdi>Dummie1138</bdi></a>  You might want to use QVector instead, which has resize. In Qt6 QList and QVector are the same anyway.<br />
If not then you'll have to add them one by one e.g. like this, but it's not very efficient for a large n:</p>
<pre><code>list.reserve(n);
std::fill_n(std::back_inserter(list), n, 0);
</code></pre>
]]></description><link>https://forum.qt.io/post/733465</link><guid isPermaLink="true">https://forum.qt.io/post/733465</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Thu, 20 Oct 2022 12:46:28 GMT</pubDate></item><item><title><![CDATA[Reply to Resizing QList for Qt5 on Thu, 20 Oct 2022 12:46:10 GMT]]></title><description><![CDATA[<p dir="auto">Thanks a lot, I'm still new, wasn't aware that allocating the space would automatically resize the list.</p>
<p dir="auto">In regards to manually appending the list, I have the following code:</p>
<pre><code>    for (int h = 0; h &lt;= binMantissa.size(); h++){
        binMantissa.replace(h, 0);
    }
</code></pre>
<p dir="auto">Is there a better way of doing it in Qt5 or is there a function that replaces all elements of a value?</p>
]]></description><link>https://forum.qt.io/post/733464</link><guid isPermaLink="true">https://forum.qt.io/post/733464</guid><dc:creator><![CDATA[Dummie1138]]></dc:creator><pubDate>Thu, 20 Oct 2022 12:46:10 GMT</pubDate></item><item><title><![CDATA[Reply to Resizing QList for Qt5 on Thu, 20 Oct 2022 12:28:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dummie1138">@<bdi>Dummie1138</bdi></a> <a href="https://doc.qt.io/qt-5/qlist.html#reserve" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qlist.html#reserve</a></p>
]]></description><link>https://forum.qt.io/post/733458</link><guid isPermaLink="true">https://forum.qt.io/post/733458</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 20 Oct 2022 12:28:02 GMT</pubDate></item></channel></rss>