<?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[single QProgressDialog button push produces two signals]]></title><description><![CDATA[<p dir="auto">Hi all -</p>
<pre><code>m_fileTransferDialog = new QProgressDialog("Transferring file", "Abort Transfer", 0, 100, this);
QObject::connect(m_fileTransferDialog, &amp;QProgressDialog::canceled, this, &amp;Widget::relayTransferCanceled);
 m_fileTransferDialog-&gt;open();
</code></pre>
<p dir="auto">I press the cancel button and get two calls to my slot. What might I be doing wrong?</p>
]]></description><link>https://forum.qt.io/topic/95985/single-qprogressdialog-button-push-produces-two-signals</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 20:53:00 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/95985.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 26 Oct 2018 19:43:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Mon, 29 Oct 2018 15:58:42 GMT]]></title><description><![CDATA[<p dir="auto">I think I may have found at least part of the problem. It seems that my call to close() emits the canceled() signal, which was getting me in trouble, as my slot wasn't prepared for a signal under these circumstances. I guess I'm not supposed to call close(), which is actually a slot.</p>
<p dir="auto">My app seems to be working now. I'm going to keep this unsolved for another day, just in case someone has something else to add.</p>
<p dir="auto">So</p>
]]></description><link>https://forum.qt.io/post/489801</link><guid isPermaLink="true">https://forum.qt.io/post/489801</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Mon, 29 Oct 2018 15:58:42 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Sat, 27 Oct 2018 13:59:48 GMT]]></title><description><![CDATA[<p dir="auto">Hi Jon - all good suggestions, and all appreciated. I don't know of any reason I can't delete from a slot, but I did convert it to deleteLater().</p>
<p dir="auto">I thought I'd already tried your suggestion to use disconnect() without success, but I tried it again, and now it seems to work.</p>
<pre><code>void Widget::showFileTransfer()
{
    m_fileTransferDialog = new QProgressDialog("Transferring file", "Abort Transfer", 0, 100, this);
    QObject::connect(this, &amp;Widget::progressChanged, m_fileTransferDialog, &amp;QProgressDialog::setValue);
    QObject::connect(m_fileTransferDialog, &amp;QProgressDialog::canceled, this, &amp;Widget::relayTransferCanceled);
    m_fileTransferDialog-&gt;show();
}

void Widget::relayTransferCanceled()
{
    QObject::disconnect(m_fileTransferDialog, &amp;QProgressDialog::canceled, nullptr, nullptr);
    emit transferCanceled();
    deleteProgressDialog(FILE_TRANSFER_CANCELED);
}
</code></pre>
<p dir="auto">I'd like to get to the bottom of this issue, so I'm going to leave it as unsolved for a few days, but at least I have a workaround. Thanks.</p>
]]></description><link>https://forum.qt.io/post/489422</link><guid isPermaLink="true">https://forum.qt.io/post/489422</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Sat, 27 Oct 2018 13:59:48 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Sat, 27 Oct 2018 09:00:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a><br />
So the second call to the slot is coming from your <code>Widget::deleteProgressDialog()</code> on line <code>m_fileTransferDialog-&gt;close();</code></p>
<p dir="auto">I know <em>nothing</em> about this, but does closing the dialog cause the  <code>QProgressDialog::canceled</code> signal to be raised?  Does <em>unconnecting</em> that signal prior to <code>m_fileTransferDialog-&gt;close();</code> solve your problem?  take a look at <a href="https://www.qtcentre.org/threads/53056-QProgressDialog-cancel-signal-is-emitted-always" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.qtcentre.org/threads/53056-QProgressDialog-cancel-signal-is-emitted-always</a> ?</p>
<p dir="auto">Also, you are calling <code>deleteProgressDialog()</code> in your <code>relayTransferCanceled()</code> slot.  Should you/is it safe to be going</p>
<pre><code>    m_fileTransferDialog-&gt;close();
    delete m_fileTransferDialog;
</code></pre>
<p dir="auto">from a slot?  Should it be more link <code>deleteLater()</code>?</p>
<p dir="auto">These are just thoughts for you!  I know <em>nothing</em>... :)</p>
]]></description><link>https://forum.qt.io/post/489383</link><guid isPermaLink="true">https://forum.qt.io/post/489383</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Sat, 27 Oct 2018 09:00:09 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 22:39:20 GMT]]></title><description><![CDATA[<p dir="auto">Sorry about that. The stack quickly enters Qt space, so I can't do much with it myself. Interesting, though, that the 2nd iteration shows my code on level 17 whereas the 1st one doesn't.</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/9a4c1c17-76ef-4c5d-bc30-ac8f426cdc27.PNG" alt="0_1540593442509_first.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/d7b376b4-4ffd-48e1-9348-3352f6e42d59.PNG" alt="0_1540593446800_second.PNG" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/489349</link><guid isPermaLink="true">https://forum.qt.io/post/489349</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Fri, 26 Oct 2018 22:39:20 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 22:23:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a><br />
Can't read the full name in column <code>Function</code>.  The second one is to do with <code>Widget::deleteP...</code> and <code>QWidget::close</code>, clue?</p>
]]></description><link>https://forum.qt.io/post/489348</link><guid isPermaLink="true">https://forum.qt.io/post/489348</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 26 Oct 2018 22:23:27 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 22:16:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a>: not until you get fairly deep:</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/9a72e9dd-b3a9-43b2-a875-0f82c847894b.PNG" alt="0_1540592128270_first.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/938931ec-5b88-4230-9ad0-5418069f8d8a.PNG" alt="0_1540592135667_second.PNG" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/489347</link><guid isPermaLink="true">https://forum.qt.io/post/489347</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Fri, 26 Oct 2018 22:16:42 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 22:04:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a> said in <a href="/post/489321">single QProgressDialog button push produces two signals</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> that's exactly what it does -- crash on the second close() attempt.</p>
</blockquote>
<p dir="auto">Aha!  OK, you didn't say that :)</p>
<p dir="auto">So I presume when you hit each time the stacktraces don't reveal anything different?</p>
]]></description><link>https://forum.qt.io/post/489344</link><guid isPermaLink="true">https://forum.qt.io/post/489344</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 26 Oct 2018 22:04:42 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 21:59:13 GMT]]></title><description><![CDATA[<p dir="auto">Just one, and I want the dialog to block. The file transfer is for tranferring OTA firmware updates, so multiple concurrent transfers are unnecessary and would be prone to causing all kinds of trouble.</p>
]]></description><link>https://forum.qt.io/post/489341</link><guid isPermaLink="true">https://forum.qt.io/post/489341</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Fri, 26 Oct 2018 21:59:13 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 21:56:18 GMT]]></title><description><![CDATA[<p dir="auto">How many file transfert can you have ?</p>
<p dir="auto">If several, you should reconsider your dialog and give it the capability to show information for more than one transfert.</p>
]]></description><link>https://forum.qt.io/post/489340</link><guid isPermaLink="true">https://forum.qt.io/post/489340</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 26 Oct 2018 21:56:18 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 21:32:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> that's exactly what it does -- crash on the second close() attempt.</p>
<p dir="auto">In looking at the canceled() signal, I wonder if I should disconnect it from the default slot cancel() before I use it. I notice that closing the window also triggers the signal.</p>
<p dir="auto">EDIT:</p>
<p dir="auto">Tried the above, no help. I'm definitely doing something to cause this code to execute twice, but I sure don't know what it is. Here's the latest effort:</p>
<pre><code>void Widget::showFileTransfer()
{
    m_fileTransferDialog = new QProgressDialog("Transferring file", "Abort Transfer", 0, 100, this);
    QObject::connect(this, &amp;Widget::progressChanged, m_fileTransferDialog, &amp;QProgressDialog::setValue);
    QObject::connect(m_fileTransferDialog, &amp;QProgressDialog::canceled, this, &amp;Widget::relayTransferCanceled);
    m_fileTransferDialog-&gt;show();
}

void Widget::relayTransferCanceled()
{
    emit transferCanceled();
    deleteProgressDialog(false);void Widget::deleteProgressDialog(bool success)
}
void Widget::deleteProgressDialog(bool success)
{
    QString title;
    QString text;

    if (success)
    {
        title = "File Transfer Complete";
        text = "The file transfer has completed.";
    }
    else
    {
        title = "File Transfer Did Not Complete";
        text = "The file transfer did not complete successfully.";
    }

    QMessageBox *qmb;

    qmb = new QMessageBox(QMessageBox::NoIcon,
                    title,
                    text,
                    QMessageBox::Ok,
                    this);
    qmb-&gt;exec();
    m_fileTransferDialog-&gt;close();
    delete m_fileTransferDialog;
    delete qmb;
}
</code></pre>
]]></description><link>https://forum.qt.io/post/489321</link><guid isPermaLink="true">https://forum.qt.io/post/489321</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Fri, 26 Oct 2018 21:32:30 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 20:54:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a><br />
If you say <code>relayTransferCanceled()</code> is called twice, what is the value of <code>m_fileTransferDialog</code> second time?  You can put a breakpoint to see it hitting <code>delete m_fileTransferDialog;</code>.  So really it should crash on the second time (on the <code>m_fileTransferDialog-&gt;close();</code>), unless the calls have quite distinct <code>m_fileTransferDialog;</code>s?</p>
]]></description><link>https://forum.qt.io/post/489320</link><guid isPermaLink="true">https://forum.qt.io/post/489320</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 26 Oct 2018 20:54:35 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 20:29:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> good point, and I'll correct that. I don't think it has any bearing on this problem though, as this issue occurs the first time through the code.</p>
]]></description><link>https://forum.qt.io/post/489316</link><guid isPermaLink="true">https://forum.qt.io/post/489316</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Fri, 26 Oct 2018 20:29:40 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 20:26:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a> said in <a href="/post/489292">single QProgressDialog button push produces two signals</a>:</p>
<blockquote>
<p dir="auto">m_fileTransferDialog</p>
</blockquote>
<p dir="auto">You only delete the QProgressDialog when it's canceled, at least in the show you've shown us.</p>
]]></description><link>https://forum.qt.io/post/489315</link><guid isPermaLink="true">https://forum.qt.io/post/489315</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 26 Oct 2018 20:26:39 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 20:24:43 GMT]]></title><description><![CDATA[<p dir="auto">I only create that object in one place, and according to the debugger, it's only getting called once.</p>
<p dir="auto">I've deleted the build directory and rebuilt...same results.</p>
]]></description><link>https://forum.qt.io/post/489314</link><guid isPermaLink="true">https://forum.qt.io/post/489314</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Fri, 26 Oct 2018 20:24:43 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 20:15:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a> said in <a href="/post/489305">single QProgressDialog button push produces two signals</a>:</p>
<blockquote>
<p dir="auto">The QDialog documentation doesn't really go into the difference between show() and open(), but they look almost identical in this use instance.</p>
</blockquote>
<p dir="auto">The latter is just <code>show()</code> for a modal dialog (i.e. it calls <code>setModal(true)</code> for you). I had that anti-epiphany due to <code>QProgress</code>'s own <code>open()</code> overload, which allows you to bind a function pointer to one of the dialog's signals. Anyway.<br />
Is it possible you have created 2 dialogs and due to having two objects emitting the signal you get to the slot twice? That'd be the most "obvious" thing I'd check as you're holding objects as members and it happens to us all (unfortunately) to forget having an object and just replacing the pointer member variable without realizing.</p>
]]></description><link>https://forum.qt.io/post/489309</link><guid isPermaLink="true">https://forum.qt.io/post/489309</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Fri, 26 Oct 2018 20:15:44 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 20:08:20 GMT]]></title><description><![CDATA[<p dir="auto">Yeah, I was wondering how that was going to make a difference. The QDialog documentation doesn't really go into the difference between show() and open(), but they look almost identical in this use instance.</p>
]]></description><link>https://forum.qt.io/post/489305</link><guid isPermaLink="true">https://forum.qt.io/post/489305</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Fri, 26 Oct 2018 20:08:20 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 20:05:03 GMT]]></title><description><![CDATA[<p dir="auto"><s>Use <code>show()</code>, not <code>open()</code>.</s></p>
<p dir="auto">Disregard, I must've had a brain aneurysm or something.</p>
]]></description><link>https://forum.qt.io/post/489299</link><guid isPermaLink="true">https://forum.qt.io/post/489299</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Fri, 26 Oct 2018 20:05:03 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 19:54:54 GMT]]></title><description><![CDATA[<p dir="auto">I only call that code once (per file transfer).</p>
<p dir="auto">I hadn't been destroying the object, but now I do (same results). Here's the slot:</p>
<pre><code>void Widget::relayTransferCanceled()
{
    emit fwUpdateCanceled();
    m_fileTransferDialog-&gt;close();
    delete m_fileTransferDialog;
    QMessageBox qmb(QMessageBox::NoIcon,
                    "File Transfer Canceled",
                    "The file transfer has been canceled.",
                    QMessageBox::Ok,
                    this);
}
</code></pre>
]]></description><link>https://forum.qt.io/post/489298</link><guid isPermaLink="true">https://forum.qt.io/post/489298</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Fri, 26 Oct 2018 19:54:54 GMT</pubDate></item><item><title><![CDATA[Reply to single QProgressDialog button push produces two signals on Fri, 26 Oct 2018 19:44:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Does that code get called several times ?<br />
Do you properly delete <code>m_fileTransferDialog </code> after use or before calling that part ?</p>
]]></description><link>https://forum.qt.io/post/489293</link><guid isPermaLink="true">https://forum.qt.io/post/489293</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 26 Oct 2018 19:44:45 GMT</pubDate></item></channel></rss>