<?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[2D QVector of QLabel]]></title><description><![CDATA[<p dir="auto">Hello,<br />
i have created the following 2D QVector of QLabels and i wanted to set a Pixmap on all of the labels. My goal is to have a 5x5 field filled with Pixmaps.</p>
<pre><code>QVector&lt;QVector&lt;QLabel*&gt;&gt; labels
{
    {0, 0, 0, 0 ,0},
    {0, 0, 0, 0 ,0},
    {0, 0, 0, 0 ,0},
    {0, 0, 0, 0 ,0},
    {0, 0, 0, 0 ,0}
};

</code></pre>
<p dir="auto">The MainWindow code looks like this:</p>
<pre><code>    ui-&gt;setupUi(this);
    this-&gt;setWindowTitle("Lawnmower");

    for (int i = 0; i &lt; 5; i++)
    {
        for (int j = 0; j &lt; 5; j++)
        {
            labels[i][j]-&gt;setPixmap(NotMowed);
            labels[i][j]-&gt;setGeometry(labelPosX, labelPosY, 200, 100);
            labelPosX += 172;
            if (i == 0 || i == 1 || i == 2 || i == 3 || i == 4)
            {
                labelPosX = 0;
                labelPosY += 100;
            }
        }
    }
</code></pre>
<p dir="auto">Dont mind the Variables labelPosX and labelPosY i just made them for setting the size and position.<br />
Anyways suddenly when i try to start it i get a segmentation fault. Can anyone help me? Thanks for your response. :)</p>
]]></description><link>https://forum.qt.io/topic/139860/2d-qvector-of-qlabel</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 00:38:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139860.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 Oct 2022 07:32:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 2D QVector of QLabel on Fri, 07 Oct 2022 07:44:27 GMT]]></title><description><![CDATA[<p dir="auto">Yes thanks for your quick answer!<br />
And yea unfortunately i forgot to initialise the labels, so i added this code:</p>
<pre><code>for (int i = 0; i &lt; 5; i++)
        for (int j = 0; j &lt; 5; j++)
            labels[i][j] = new QLabel(this);
</code></pre>
<p dir="auto">Just in case of other people having the same mistake and not knowing what they did wrong/forgot.</p>
]]></description><link>https://forum.qt.io/post/731664</link><guid isPermaLink="true">https://forum.qt.io/post/731664</guid><dc:creator><![CDATA[Qt-User0307]]></dc:creator><pubDate>Fri, 07 Oct 2022 07:44:27 GMT</pubDate></item><item><title><![CDATA[Reply to 2D QVector of QLabel on Fri, 07 Oct 2022 07:38:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qt-user0307">@<bdi>Qt-User0307</bdi></a> did you ever initialise the 25 QLabels ? I don't see that anywhere from what you've shown here.</p>
<p dir="auto">Besides that, use a Debugger</p>
]]></description><link>https://forum.qt.io/post/731660</link><guid isPermaLink="true">https://forum.qt.io/post/731660</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Fri, 07 Oct 2022 07:38:20 GMT</pubDate></item></channel></rss>