<?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[Storing and setting widget values using arrays?]]></title><description><![CDATA[<p dir="auto">So i have many knobs, sliders, lineedits and they all have values obviously, but now as they are getting more and more i was looking to just store the values in a way that its exactly clear which value belongs to which widget and so i can set and store all the values at once using a loop or so.</p>
<p dir="auto">Any recommendations on how to do that? Is it possible to have arrays which various ui widgets stored in them?<br />
Also till now i've declared them and added that to layouts all by hand is there an easier approach that makes the code less cluttered?</p>
<p dir="auto">Thanks in advance. :) Have a nice day.</p>
]]></description><link>https://forum.qt.io/topic/155418/storing-and-setting-widget-values-using-arrays</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 08:36:47 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/155418.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Mar 2024 11:43:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Storing and setting widget values using arrays? on Tue, 19 Mar 2024 11:54:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/studentscripter">@<bdi>StudentScripter</bdi></a><br />
You can put <em>pointers to</em> widgets into arrays/lists/maps as you please and use those for iterating through them etc.</p>
<p dir="auto">You can't get <strong>Designer</strong> to do that for you, so you have to manually populate the arrays/lists from the <code>ui-&gt;...</code> instance variables yourself (after <code>setupUi()</code>).</p>
<p dir="auto">You can also <em>visit</em> all widgets of a given type, without setting anything up, via <code>topWidget-&gt;findChildren&lt;QLineEdit *&gt;()</code>.</p>
<p dir="auto">You can "group" widgets at design-time by e.g. creating a "holding" container <code>QWidget</code> or <code>QFrame</code> or <code>QGroupBox</code> if that helps.  For buttons there is also <code>QButtonGroup</code>.</p>
]]></description><link>https://forum.qt.io/post/793712</link><guid isPermaLink="true">https://forum.qt.io/post/793712</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 19 Mar 2024 11:54:53 GMT</pubDate></item><item><title><![CDATA[Reply to Storing and setting widget values using arrays? on Tue, 19 Mar 2024 11:55:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/studentscripter">@<bdi>StudentScripter</bdi></a> said in <a href="/post/793708">Storing and setting widget values using arrays?</a>:</p>
<blockquote>
<p dir="auto">i was looking to just store the values in a way that its exactly clear which value belongs to which widget</p>
</blockquote>
<p dir="auto">I mean, each widget already stores its value or data.</p>
<p dir="auto">If you still want to store it separately, you could use a <code>struct</code>, <code>QMap</code>/<code>QHash</code> or some data model (not all widgets support that).</p>
<blockquote>
<p dir="auto">Is it possible to have arrays which various ui widgets stored in them?</p>
</blockquote>
<p dir="auto"><code>QVector&lt;QWidget* &gt;</code>?! Why should it not be possible?</p>
<blockquote>
<p dir="auto">Also till now i've declared them and added that to layouts all by hand is there an easier approach that makes the code less cluttered?</p>
</blockquote>
<p dir="auto">Either add widgets by code or use <code>.ui</code> files. There is no other way :)</p>
]]></description><link>https://forum.qt.io/post/793711</link><guid isPermaLink="true">https://forum.qt.io/post/793711</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Tue, 19 Mar 2024 11:55:49 GMT</pubDate></item></channel></rss>