<?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[Close QDialog: Not calling the on_clicked() method]]></title><description><![CDATA[<p dir="auto">I'm developing a Qt C++ GUI <code>shared library</code>.</p>
<pre><code>void Plugin::showUI() const {
    Dialog a;

    a.setModal(true);
    a.exec();
}
</code></pre>
<p dir="auto">My UI have a buttom called "Save".</p>
<pre><code>void Dialog::on_save_btn_clicked()
{
    qDebug() &lt;&lt; "SAVE";
}
</code></pre>
<p dir="auto">It compiles without any warnings or errors. All ok!<br />
The plugin UI appears ok too.</p>
<p dir="auto">My problem: When I click on the save button, <strong>the method above is not called! Why?</strong></p>
<p dir="auto"><strong>How can I fix it?</strong></p>
]]></description><link>https://forum.qt.io/topic/117226/close-qdialog-not-calling-the-on_clicked-method</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 00:23:39 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/117226.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Jul 2020 20:34:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Close QDialog: Not calling the on_clicked() method on Wed, 22 Jul 2020 00:17:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fem_dev">@<bdi>fem_dev</bdi></a> said in <a href="/post/608081">Close QDialog: Not calling the on_clicked() method</a>:</p>
<blockquote>
<p dir="auto">I just added this "save_btn_clicked" from the Qt Designer using: right-click -&gt; Go To Slot -&gt; Clicked()</p>
</blockquote>
<p dir="auto">It can't be...The "save_btn_clicked" function is not even a slot!<br />
That's why it doesn't work...<br />
If you create it using designer, it should be added as a slot like this:</p>
<pre><code>private slots:
    void on_save_btn_clicked();
</code></pre>
<p dir="auto">Unless you've deleted that "private slots:" line.</p>
]]></description><link>https://forum.qt.io/post/608090</link><guid isPermaLink="true">https://forum.qt.io/post/608090</guid><dc:creator><![CDATA[Bonnie]]></dc:creator><pubDate>Wed, 22 Jul 2020 00:17:28 GMT</pubDate></item><item><title><![CDATA[Reply to Close QDialog: Not calling the on_clicked() method on Wed, 22 Jul 2020 13:33:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bonnie">@<bdi>Bonnie</bdi></a> said in <a href="/post/608090">Close QDialog: Not calling the on_clicked() method</a>:</p>
<blockquote>
<p dir="auto">Unless you've deleted that "private slots:" line.</p>
</blockquote>
<p dir="auto">Perfect <a class="plugin-mentions-user plugin-mentions-a" href="/user/bonnie">@<bdi>Bonnie</bdi></a> ....I've deleted this line...<br />
Thank you!</p>
]]></description><link>https://forum.qt.io/post/608244</link><guid isPermaLink="true">https://forum.qt.io/post/608244</guid><dc:creator><![CDATA[fem_dev]]></dc:creator><pubDate>Wed, 22 Jul 2020 13:33:13 GMT</pubDate></item><item><title><![CDATA[Reply to Close QDialog: Not calling the on_clicked() method on Wed, 22 Jul 2020 00:17:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fem_dev">@<bdi>fem_dev</bdi></a> said in <a href="/post/608081">Close QDialog: Not calling the on_clicked() method</a>:</p>
<blockquote>
<p dir="auto">I just added this "save_btn_clicked" from the Qt Designer using: right-click -&gt; Go To Slot -&gt; Clicked()</p>
</blockquote>
<p dir="auto">It can't be...The "save_btn_clicked" function is not even a slot!<br />
That's why it doesn't work...<br />
If you create it using designer, it should be added as a slot like this:</p>
<pre><code>private slots:
    void on_save_btn_clicked();
</code></pre>
<p dir="auto">Unless you've deleted that "private slots:" line.</p>
]]></description><link>https://forum.qt.io/post/608090</link><guid isPermaLink="true">https://forum.qt.io/post/608090</guid><dc:creator><![CDATA[Bonnie]]></dc:creator><pubDate>Wed, 22 Jul 2020 00:17:28 GMT</pubDate></item><item><title><![CDATA[Reply to Close QDialog: Not calling the on_clicked() method on Tue, 21 Jul 2020 20:46:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> sorry...here is my <code>Dialog</code> class.</p>
<pre><code>#ifndef DIALOG_H
#define DIALOG_H

#include &lt;QDialog&gt;

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT

public:
    explicit Dialog(QWidget *parent = nullptr);
    ~Dialog();

    void on_save_btn_clicked();

private:
    Ui::Dialog *ui;
};

#endif // DIALOG_H
</code></pre>
<pre><code>#include "dialog.h"
#include "ui_dialog.h"

#include &lt;QDebug&gt;

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui-&gt;setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_save_btn_clicked()
{
    qDebug() &lt;&lt; "SAVE";
}
</code></pre>
<p dir="auto">I just added this "save_btn_clicked" from the Qt Designer using: right-click -&gt; Go To Slot -&gt; Clicked()</p>
]]></description><link>https://forum.qt.io/post/608081</link><guid isPermaLink="true">https://forum.qt.io/post/608081</guid><dc:creator><![CDATA[fem_dev]]></dc:creator><pubDate>Tue, 21 Jul 2020 20:46:26 GMT</pubDate></item><item><title><![CDATA[Reply to Close QDialog: Not calling the on_clicked() method on Tue, 21 Jul 2020 20:36:14 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Without the code form Dialog, it's hard to guess...</p>
]]></description><link>https://forum.qt.io/post/608080</link><guid isPermaLink="true">https://forum.qt.io/post/608080</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 21 Jul 2020 20:36:14 GMT</pubDate></item></channel></rss>