<?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[QTimer with QProgressbar]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I am trying to make my progressbar flow by time so I connected a progressbar to a QTimer. Here is my code:</p>
<pre><code>void MainWindow::progressbarTimer(QString TimeSet)
{
    ui-&gt;progressBar-&gt;setMaximum(TimeSet.toInt()*1000);
    QTimer *timer = new QTimer(this);
    currenttime = TimeSet.toInt();
    connect(timer, SIGNAL(timeout()), this, SLOT(updateProgresbar()));
    timer-&gt;start(1);
}

void MainWindow::updateProgresbar()
{
    if(counter &lt;= currenttime*1000)
    {
        counter++;
        ui-&gt;progressBar-&gt;setValue(counter);
    }
    else
    {
        timer-&gt;stop();
        delete timer;
    }
}
</code></pre>
<p dir="auto">Unfortunately I can't seem to input parameters into the updateProgresbar slot to make use of the timer in  the function. Anyone got a solution for this? Thanks in advance!</p>
]]></description><link>https://forum.qt.io/topic/57469/qtimer-with-qprogressbar</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 21:34:58 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/57469.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Aug 2015 12:04:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QTimer with QProgressbar on Tue, 11 Aug 2015 08:30:26 GMT]]></title><description><![CDATA[<p dir="auto">Hio,<br />
What SGaist said is that your timer (QTimer) in void MainWindow::progressbarTimer() has function scope. So when you end the function, the timer variable is no longer available. Because you don't delete it and it has a signal/slot connection the timer is still active in the eventloop. So calling the updateProgressBar is no problem. To reference again to that timer is not valid!! the timer-&gt; will give errors??</p>
]]></description><link>https://forum.qt.io/post/286026</link><guid isPermaLink="true">https://forum.qt.io/post/286026</guid><dc:creator><![CDATA[Jeroentjehome]]></dc:creator><pubDate>Tue, 11 Aug 2015 08:30:26 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer with QProgressbar on Tue, 11 Aug 2015 08:23:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Hi, thanks for your reply. I know it is not the same. My question is how I can get it the same.</p>
]]></description><link>https://forum.qt.io/post/286024</link><guid isPermaLink="true">https://forum.qt.io/post/286024</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 11 Aug 2015 08:23:03 GMT</pubDate></item><item><title><![CDATA[Reply to QTimer with QProgressbar on Wed, 05 Aug 2015 20:35:02 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">You declare timer in progressbarTimer so it's not the same as the one you have in updateProgresbar.</p>
]]></description><link>https://forum.qt.io/post/285513</link><guid isPermaLink="true">https://forum.qt.io/post/285513</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 05 Aug 2015 20:35:02 GMT</pubDate></item></channel></rss>