<?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[Having problems deleting and adding widgets to a layout.]]></title><description><![CDATA[<p dir="auto">So basically I've got a situation where I've got a square grid of QLineEdit widgets. So I've got a function that builds the grid that gets called by the constructor for the grid object and is signaled by pressing return on a QLineEdit to change the dimension, it looks something like this:</p>
<pre><code>void GridUI::buildGrid() {
    //Grab the dimension size from the input
    gridDimension = dimensionInput-&gt;text().toInt();

    //Delete all the widgets in the grid if they already exist
    //puzzleGridCell is a QGridLayout instantiated in the constructor
    QLayoutItem *toDelete;
    while ((toDelete = puzzleGridCell-&gt;takeAt(0)) != 0)
        delete toDelete-&gt;widget();
    
    //Create the grid
    for (int puzzCol = 0; puzzCol &lt; gridDimension; ++puzzCol) {
        for (int puzzRow = 0; puzzRow &lt; gridDimension; ++puzzRow) {
            QLineEdit *puzzBox = new QLineEdit("", this);
            puzzleGridCell-&gt;addWidget(puzzBox, puzzCol, puzzRow);
        }
    }
}
</code></pre>
<p dir="auto">What's going wrong is that it's building properly to start, but when I change the dimension and press return it removes all of the QLineEdits, but doesn't seem to resize the grid or show the new QLineEdit widgets, I can tell through debugging that they're at least getting created and added to the QGridLayout, but they're just not showing up at all.</p>
<p dir="auto">Just wanted to see if there was something really obvious that I'm not aware of, or maybe if anyone's got any ideas on what to look at.</p>
]]></description><link>https://forum.qt.io/topic/98739/having-problems-deleting-and-adding-widgets-to-a-layout</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 02:51:26 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/98739.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Jan 2019 00:48:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Having problems deleting and adding widgets to a layout. on Mon, 21 Jan 2019 05:53:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/blakejustblake">@<bdi>blakejustblake</bdi></a> Yes, you need to call show()</p>
]]></description><link>https://forum.qt.io/post/506043</link><guid isPermaLink="true">https://forum.qt.io/post/506043</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 21 Jan 2019 05:53:12 GMT</pubDate></item><item><title><![CDATA[Reply to Having problems deleting and adding widgets to a layout. on Mon, 21 Jan 2019 05:51:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> Definitely something obvious I wasn't aware of. Thanks. So if add any children after initially showing a widget I need to additionally show them as well?</p>
]]></description><link>https://forum.qt.io/post/506042</link><guid isPermaLink="true">https://forum.qt.io/post/506042</guid><dc:creator><![CDATA[blakejustblake]]></dc:creator><pubDate>Mon, 21 Jan 2019 05:51:43 GMT</pubDate></item><item><title><![CDATA[Reply to Having problems deleting and adding widgets to a layout. on Mon, 21 Jan 2019 05:38:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/blakejustblake">@<bdi>blakejustblake</bdi></a> The new line edits are not shown because you do not call show() on them:</p>
<pre><code>QLineEdit *puzzBox = new QLineEdit("", this);
puzzleGridCell-&gt;addWidget(puzzBox, puzzCol, puzzRow);
puzzBox-&gt;show();
</code></pre>
]]></description><link>https://forum.qt.io/post/506038</link><guid isPermaLink="true">https://forum.qt.io/post/506038</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 21 Jan 2019 05:38:02 GMT</pubDate></item></channel></rss>