<?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[A QCheckBox used by other functions]]></title><description><![CDATA[<p dir="auto">I make a To Do list, so far I have 2 function, the 1 function adds a QCheckBox at click and the 2 function must delete the QCheckBox which are "Checked" but I don't know how to do that.</p>
<p dir="auto">menuwindow.cpp:</p>
<p dir="auto">this funktion must delete the QCheckBox</p>
<pre><code>void MenuWindow::on_alle_loschen_2_clicked()
{

    if(aufgabe-&gt;isChecked()){
        aufgabe-&gt;hide();
    }
}
</code></pre>
<p dir="auto">this funktion add the new QCheckBox</p>
<pre><code>void MenuWindow::on_einfugen_clicked()
{
    QCheckBox *aufgabe = new QCheckBox(ui-&gt;aufgabe_einfugen-&gt;text());
    ui-&gt;aufgaben_liste-&gt;addWidget(aufgabe);

     }
</code></pre>
<p dir="auto">menuwindow.h</p>
<pre><code>private slots:

    void on_alle_loschen_2_clicked();

    void on_einfugen_clicked();

private:
    QCheckBox *aufgabe;
    Ui::MenuWindow *ui;
</code></pre>
]]></description><link>https://forum.qt.io/topic/139127/a-qcheckbox-used-by-other-functions</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 15:48:13 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139127.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Sep 2022 13:57:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to A QCheckBox used by other functions on Tue, 06 Sep 2022 20:13:11 GMT]]></title><description><![CDATA[<p dir="auto">Code that delete all checked checkbox from a formlayout at ui-&gt;formLayout:</p>
<pre><code>QList&lt;QCheckBox*&gt; boxes;
for(int i=0; i&lt;ui-&gt;formLayout-&gt;rowCount(); i++)
    {
    QCheckBox* box=qobject_cast&lt;QCheckBox*&gt;(ui-&gt;formLayout-&gt;itemAt(i,QFormLayout::FieldRole)-&gt;widget());
    if(box &amp;&amp; box-&gt;isChecked())
        boxes&lt;&lt;box;
    }

for(QWidget* w : boxes)
    ui-&gt;formLayout-&gt;removeRow(w);
</code></pre>
]]></description><link>https://forum.qt.io/post/727674</link><guid isPermaLink="true">https://forum.qt.io/post/727674</guid><dc:creator><![CDATA[mpergand]]></dc:creator><pubDate>Tue, 06 Sep 2022 20:13:11 GMT</pubDate></item><item><title><![CDATA[Reply to A QCheckBox used by other functions on Tue, 06 Sep 2022 19:30:39 GMT]]></title><description><![CDATA[<p dir="auto">Why a QFormLayout if there's label added with the checkbox ?</p>
<p dir="auto">Use <a href="https://doc.qt.io/qt-6/qlayout.html#itemAt" target="_blank" rel="noopener noreferrer nofollow ugc">itemAt</a> and from there the widget to check its state. You can then remove and delete it.</p>
]]></description><link>https://forum.qt.io/post/727669</link><guid isPermaLink="true">https://forum.qt.io/post/727669</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 06 Sep 2022 19:30:39 GMT</pubDate></item><item><title><![CDATA[Reply to A QCheckBox used by other functions on Tue, 06 Sep 2022 19:19:23 GMT]]></title><description><![CDATA[<p dir="auto">The checkbox must be deleted when button was printed and ChekBox is "Checked"</p>
]]></description><link>https://forum.qt.io/post/727667</link><guid isPermaLink="true">https://forum.qt.io/post/727667</guid><dc:creator><![CDATA[Maksims]]></dc:creator><pubDate>Tue, 06 Sep 2022 19:19:23 GMT</pubDate></item><item><title><![CDATA[Reply to A QCheckBox used by other functions on Tue, 06 Sep 2022 19:05:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/maksims">@<bdi>Maksims</bdi></a><br />
Delete the checkBox as soon it was clicked,<br />
is really what you want to do ?</p>
]]></description><link>https://forum.qt.io/post/727662</link><guid isPermaLink="true">https://forum.qt.io/post/727662</guid><dc:creator><![CDATA[mpergand]]></dc:creator><pubDate>Tue, 06 Sep 2022 19:05:52 GMT</pubDate></item><item><title><![CDATA[Reply to A QCheckBox used by other functions on Tue, 06 Sep 2022 18:54:49 GMT]]></title><description><![CDATA[<p dir="auto">I use QFormLayout</p>
]]></description><link>https://forum.qt.io/post/727660</link><guid isPermaLink="true">https://forum.qt.io/post/727660</guid><dc:creator><![CDATA[Maksims]]></dc:creator><pubDate>Tue, 06 Sep 2022 18:54:49 GMT</pubDate></item><item><title><![CDATA[Reply to A QCheckBox used by other functions on Tue, 06 Sep 2022 18:18:15 GMT]]></title><description><![CDATA[<p dir="auto">Yes with a loop.</p>
<p dir="auto">To which type of widget are you adding these check boxes ?</p>
]]></description><link>https://forum.qt.io/post/727657</link><guid isPermaLink="true">https://forum.qt.io/post/727657</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 06 Sep 2022 18:18:15 GMT</pubDate></item><item><title><![CDATA[Reply to A QCheckBox used by other functions on Tue, 06 Sep 2022 17:56:56 GMT]]></title><description><![CDATA[<p dir="auto">Do they mean for loop? I don't understand exactly how can I get to the added QCheckBoxes</p>
]]></description><link>https://forum.qt.io/post/727653</link><guid isPermaLink="true">https://forum.qt.io/post/727653</guid><dc:creator><![CDATA[Maksims]]></dc:creator><pubDate>Tue, 06 Sep 2022 17:56:56 GMT</pubDate></item><item><title><![CDATA[Reply to A QCheckBox used by other functions on Tue, 06 Sep 2022 16:51:36 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">If you want to remove all the check boxes that are checked you need to iterate through all the ones that you added to aufgaben_liste.</p>
<p dir="auto">What you have here is a dangling pointer that will make your application crash when calling any function on it.</p>
]]></description><link>https://forum.qt.io/post/727644</link><guid isPermaLink="true">https://forum.qt.io/post/727644</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 06 Sep 2022 16:51:36 GMT</pubDate></item></channel></rss>