<?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[QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown]]></title><description><![CDATA[<p dir="auto">I'm trying to write a test before adding a progress bar to my application:</p>
<pre><code>QProgressDialog progressDialog;
progressDialog.setWindowTitle("Test");
progressDialog.setRange(0, 4);
progressDialog.setLabelText("Updating...");
progressDialog.show();
for (i = 0; i &lt; 4; i++)
{
    progressDialog.setValue(i);
    QApplication::processEvents();
    QThread::sleep(1);
}
progressDialog.close();
</code></pre>
<p dir="auto">But when the progress dialogue first appears it is messed up / corrupted:</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/01a5a75b-99fa-4149-a865-2766fa9fa139.jpg" alt="0_1527178257575_ProgressDialog.jpg" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/91027/qprogressdialog-looks-messed-up-corrupted-when-it-s-first-shown</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 16:29:31 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/91027.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 May 2018 16:11:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 23:37:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a><br />
I think the problem is that I disabled the menu using:</p>
<pre><code>setEnabled(false);
</code></pre>
<p dir="auto">When I click cancel the lambda is called twice.</p>
<p dir="auto">However I don't understand why the action is triggered even when I just select the menu and not the menu item. Perhaps this merits another question on this forum.</p>
<p dir="auto">Is it neccessary to use a mutex and flag that the algorithm has been cancelled?</p>
]]></description><link>https://forum.qt.io/post/460528</link><guid isPermaLink="true">https://forum.qt.io/post/460528</guid><dc:creator><![CDATA[Guerrian]]></dc:creator><pubDate>Sun, 27 May 2018 23:37:03 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 22:53:24 GMT]]></title><description><![CDATA[<p dir="auto">But do you mean is disabled as in setEnabled(false)<br />
or simply is unresponsive ?</p>
]]></description><link>https://forum.qt.io/post/460526</link><guid isPermaLink="true">https://forum.qt.io/post/460526</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 27 May 2018 22:53:24 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 22:46:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a><br />
No, it can't, because the cancel button is disabled on the QProgressDialog.</p>
]]></description><link>https://forum.qt.io/post/460525</link><guid isPermaLink="true">https://forum.qt.io/post/460525</guid><dc:creator><![CDATA[Guerrian]]></dc:creator><pubDate>Sun, 27 May 2018 22:46:47 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 22:17:46 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
Does it enter the "cancel" lambda ?</p>
]]></description><link>https://forum.qt.io/post/460522</link><guid isPermaLink="true">https://forum.qt.io/post/460522</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 27 May 2018 22:17:46 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 22:25:54 GMT]]></title><description><![CDATA[<p dir="auto">I followed this path and it is almost working. Unfortunately the cancel button on the progress bar is disabled. It remains disabled even after successfully updating the progress bar. The only thread I could find on this problem is here:<br />
<a href="https://forum.qt.io/topic/26619/cancel-button-on-qprogressdialog-is-unresponsive-solved">https://forum.qt.io/topic/26619/cancel-button-on-qprogressdialog-is-unresponsive-solved</a><br />
Like the author says though you don't need to connect the cancel button to a slot.</p>
<p dir="auto">I am setting up the dialog like this now:</p>
<pre><code>dialog = new QProgressDialog(tr("Performing task") + "...", tr("Cancel"), 0, 4, this);
dialog-&gt;setLabelText("Updating...");
dialog-&gt;setWindowModality(Qt::WindowModal);
connect(task, SIGNAL(advance()), this, SLOT(advance()));
connect(dialog, &amp;QProgressDialog::finished, dialog, &amp;QProgressDialog::deleteLater);
connect(dialog, &amp;QProgressDialog::canceled, this, [=] ()
{
    thread-&gt;quit();
    thread-&gt;wait();
    dialog-&gt;close();
});
</code></pre>
<p dir="auto">I'm showing the dialog like this:</p>
<pre><code>    dialog-&gt;setValue(0);
    dialog-&gt;show();
</code></pre>
<p dir="auto">I'm advancing the progress bar like this:</p>
<pre><code>void MainWindow::advance()
{
    dialog-&gt;setValue(dialog-&gt;value() + 1);
    QApplication::processEvents();
}
</code></pre>
<p dir="auto">Another strange problem which I am encountering is that the progress bar / task is sometimes started even when I click on the menu but not the menu item. I am connecting the menu item to the function using:</p>
<pre><code>connect(ui-&gt;actionTask, &amp;QAction::triggered, this, &amp;MainWindow::runTask);
</code></pre>
]]></description><link>https://forum.qt.io/post/460521</link><guid isPermaLink="true">https://forum.qt.io/post/460521</guid><dc:creator><![CDATA[Guerrian]]></dc:creator><pubDate>Sun, 27 May 2018 22:25:54 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 17:45:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guerrian">@<bdi>Guerrian</bdi></a><br />
Hi, yes if algorithm is heavy then its be best solution.<br />
You already have the GUI thread.<br />
So if you move the algorithm class to a thread and<br />
emit a signal to tell the progressbar to update then it should work lovely.<br />
<a href="https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/" target="_blank" rel="noopener noreferrer nofollow ugc">https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/</a><br />
so myAlgorithm would be the task object and moved to thread.</p>
]]></description><link>https://forum.qt.io/post/460498</link><guid isPermaLink="true">https://forum.qt.io/post/460498</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 27 May 2018 17:45:31 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 17:42:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a><br />
Can I do this with two threads, one for the GUI and the other for the algorithm?</p>
]]></description><link>https://forum.qt.io/post/460496</link><guid isPermaLink="true">https://forum.qt.io/post/460496</guid><dc:creator><![CDATA[Guerrian]]></dc:creator><pubDate>Sun, 27 May 2018 17:42:30 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 13:44:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guerrian">@<bdi>Guerrian</bdi></a><br />
Hi<br />
QProgressDialog is older than god so its very unlikely you found a bug in 2018 :)<br />
also when you use stuff like<br />
QApplication::processEvents();<br />
QThread::sleep(1);<br />
it means you try to loop in a GUI application and it always do odd stuff as you are stangulating the event loop. QApplication::processEvents() can sometimes help<br />
but its not a cure all loops magic call.</p>
<p dir="auto">signals and slot often a way better choice as it plays nice with the event loop.</p>
]]></description><link>https://forum.qt.io/post/460479</link><guid isPermaLink="true">https://forum.qt.io/post/460479</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 27 May 2018 13:44:36 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 13:34:42 GMT]]></title><description><![CDATA[<p dir="auto">If you don't pause before the first (not zero) point and process events then the progress dialogue is drawn correctly. Seems like a bug with QProgressDialog.</p>
]]></description><link>https://forum.qt.io/post/460478</link><guid isPermaLink="true">https://forum.qt.io/post/460478</guid><dc:creator><![CDATA[Guerrian]]></dc:creator><pubDate>Sun, 27 May 2018 13:34:42 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sun, 27 May 2018 00:47:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guerrian">@<bdi>Guerrian</bdi></a> Hi,friend.</p>
<p dir="auto">Very good! Don't forget to <code>Mark as Solved</code> in <code>Topic Tools</code>.</p>
]]></description><link>https://forum.qt.io/post/460421</link><guid isPermaLink="true">https://forum.qt.io/post/460421</guid><dc:creator><![CDATA[joeQ]]></dc:creator><pubDate>Sun, 27 May 2018 00:47:39 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Sat, 26 May 2018 23:15:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mranger90">@<bdi>mranger90</bdi></a></p>
<p dir="auto">I got your example to run... nice! How would I adapt it so that I can update the progress bar from within an algorithm (assuming that is possible):</p>
<pre><code>void myAlgorithm(int n)
{
    int i;
    for (i = 0; i &lt; n; i++)
    {
        someProcessingFunction(i);
        // update the progress bar here!
    }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/460413</link><guid isPermaLink="true">https://forum.qt.io/post/460413</guid><dc:creator><![CDATA[Guerrian]]></dc:creator><pubDate>Sat, 26 May 2018 23:15:58 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Fri, 25 May 2018 11:56:52 GMT]]></title><description><![CDATA[<p dir="auto">I'm still convinced this is a coding issue, not configuration.<br />
try this to see if the progress dialog is shown correctly: (m_timer is a QTimer)</p>
<pre><code>void Dialog::on_showProgress1_clicked()
{
    QProgressDialog *dlg = new QProgressDialog(this);
    connect(dlg, &amp;QProgressDialog::finished, dlg, &amp;QProgressDialog::deleteLater);
    connect(dlg, &amp;QProgressDialog::canceled, this, [=](){
        m_progressVal = 99;  // kind of cheesy, let the timer continue and cleanup
    });

    dlg-&gt;setRange(0,100);
    dlg-&gt;setWindowTitle("Test");
    dlg-&gt;setLabelText("Updating...");
    m_progressVal = 0;

    auto conn = std::make_shared&lt;QMetaObject::Connection&gt;();
    *conn = connect(&amp;m_timer, &amp;QTimer::timeout, this, [=]() {
        m_progressVal++;
        dlg-&gt;setValue(m_progressVal);

        if (m_progressVal == dlg-&gt;maximum()) {
            m_timer.stop();
            disconnect(*conn);
        }
    });

    dlg-&gt;show();

    m_timer.setInterval(100);
    m_timer.start();
}

</code></pre>
]]></description><link>https://forum.qt.io/post/460229</link><guid isPermaLink="true">https://forum.qt.io/post/460229</guid><dc:creator><![CDATA[mranger90]]></dc:creator><pubDate>Fri, 25 May 2018 11:56:52 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Fri, 25 May 2018 11:04:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a><br />
I looked at the help about dialogue in Qt Creator to get "5.5".</p>
<p dir="auto">Yeah. I'm using the version installed with the Mint software manager (5.5), so it's the same version as I'd get with "apt-get install". I don't know how to access Qt via Anaconda as it is not on the Anaconda menu.</p>
]]></description><link>https://forum.qt.io/post/460210</link><guid isPermaLink="true">https://forum.qt.io/post/460210</guid><dc:creator><![CDATA[Guerrian]]></dc:creator><pubDate>Fri, 25 May 2018 11:04:48 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Thu, 24 May 2018 20:48:35 GMT]]></title><description><![CDATA[<p dir="auto">How did you determine the version from Qt Creator ?</p>
<p dir="auto">In any case, you should first try to build your application with your distribution provided Qt.</p>
]]></description><link>https://forum.qt.io/post/460128</link><guid isPermaLink="true">https://forum.qt.io/post/460128</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 24 May 2018 20:48:35 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Thu, 24 May 2018 20:44:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a><br />
$ qmake -v<br />
QMake version 3.0<br />
Using Qt version 5.6.2 in /home/daniel/anaconda3/lib<br />
$  wmctrl -m<br />
Name: Mutter (Muffin)</p>
<p dir="auto">But Qt Creator says version 5.5.</p>
]]></description><link>https://forum.qt.io/post/460127</link><guid isPermaLink="true">https://forum.qt.io/post/460127</guid><dc:creator><![CDATA[Guerrian]]></dc:creator><pubDate>Thu, 24 May 2018 20:44:06 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Thu, 24 May 2018 19:45:09 GMT]]></title><description><![CDATA[<p dir="auto">Qt 5 is a bit vague since it goes from 5.0.0 to 5.11.0.</p>
<p dir="auto">Did you install it yourself ?<br />
If not, do you have the same problem with the Qt version provided by Mint ?<br />
What window manager are you using ?</p>
]]></description><link>https://forum.qt.io/post/460103</link><guid isPermaLink="true">https://forum.qt.io/post/460103</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 24 May 2018 19:45:09 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Thu, 24 May 2018 19:04:37 GMT]]></title><description><![CDATA[<p dir="auto">I'm using Qt 5 on Linux Mint 18.1 (Cinnamon).</p>
<p dir="auto">I tried adding more "QApplication::processEvents()", but it didn't make any difference.</p>
<p dir="auto">I think I will have to create a separate thread for the progress dialogue.</p>
]]></description><link>https://forum.qt.io/post/460099</link><guid isPermaLink="true">https://forum.qt.io/post/460099</guid><dc:creator><![CDATA[Guerrian]]></dc:creator><pubDate>Thu, 24 May 2018 19:04:37 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Thu, 24 May 2018 18:53:09 GMT]]></title><description><![CDATA[<p dir="auto">I think its the way your test is structure.  The progress dialog does not get to paint itself properly until the event loop gets to run.  So until you call processEvents() the dialog will not appear correct.</p>
]]></description><link>https://forum.qt.io/post/460097</link><guid isPermaLink="true">https://forum.qt.io/post/460097</guid><dc:creator><![CDATA[mranger90]]></dc:creator><pubDate>Thu, 24 May 2018 18:53:09 GMT</pubDate></item><item><title><![CDATA[Reply to QProgressDialog looks messed up &#x2F; corrupted when it&#x27;s first shown on Thu, 24 May 2018 18:25:47 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">What version of Qt are you using ?<br />
On what platform ?<br />
If Linux:<br />
What distribution ?<br />
What desktop environment ?</p>
]]></description><link>https://forum.qt.io/post/460090</link><guid isPermaLink="true">https://forum.qt.io/post/460090</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 24 May 2018 18:25:47 GMT</pubDate></item></channel></rss>