<?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[Updating label content every 2 minutes]]></title><description><![CDATA[<p dir="auto">Hi!!!<br />
I'm a newbie in QT Creator. I would like to implement a very simple graphical interface based on a Label and a pushButtom.<br />
When pressing the button in the label the content of a txt file appears.<br />
The thing is that this same file will be changing every 2 minutes, so I would need that automatically and without pressing the button again, in the label this new content will appear, the change does not have to be done simultaneously.<br />
What function or functions should I turn to?<br />
Thanks in advance.</p>
]]></description><link>https://forum.qt.io/topic/101637/updating-label-content-every-2-minutes</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 05:44:16 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/101637.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 10 Apr 2019 09:44:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Updating label content every 2 minutes on Thu, 11 Apr 2019 08:50:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nadales56">@<bdi>nadales56</bdi></a><br />
Hi<br />
Np<br />
Please dont forget to mark it as solved then :)</p>
]]></description><link>https://forum.qt.io/post/522470</link><guid isPermaLink="true">https://forum.qt.io/post/522470</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 11 Apr 2019 08:50:33 GMT</pubDate></item><item><title><![CDATA[Reply to Updating label content every 2 minutes on Thu, 11 Apr 2019 08:01:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a><br />
Thank you so much for your help, i really appreciate it! =)<br />
It Works really well, as i want to be worked!</p>
]]></description><link>https://forum.qt.io/post/522462</link><guid isPermaLink="true">https://forum.qt.io/post/522462</guid><dc:creator><![CDATA[nadales56]]></dc:creator><pubDate>Thu, 11 Apr 2019 08:01:05 GMT</pubDate></item><item><title><![CDATA[Reply to Updating label content every 2 minutes on Wed, 10 Apr 2019 10:32:28 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
Do like this</p>
<pre><code>class MainWindow : public QMainWindow
{
Q_OBJECT
QTimer *timer; // NEW
public:
void readFile(); // NEW to read the file and set to label
....
private slots:
void TimerSlot(); // NEW slot
private:
    Ui::MainWindow *ui;
};
</code></pre>
<pre><code>MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui-&gt;setupUi(this);
    timer = new QTimer(this); // create it
    connect(timer, &amp;QTimer::timeout, this, &amp;MainWindow::TimerSlot ); // connect it
}

void MainWindow::readFile()
{
    // QFile readALL() etc and set to ui-&gt;label
}

void MainWindow::on_pushButton_released()
{
readFile(); // read file
timer-&gt;start(120000); // 2 mins timer
}

void MainWindow::TimerSlot()
{
    readFile(); // read file again
}

</code></pre>
]]></description><link>https://forum.qt.io/post/522303</link><guid isPermaLink="true">https://forum.qt.io/post/522303</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Wed, 10 Apr 2019 10:32:28 GMT</pubDate></item><item><title><![CDATA[Reply to Updating label content every 2 minutes on Wed, 10 Apr 2019 10:25:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nadales56">@<bdi>nadales56</bdi></a><br />
hi<br />
No, no infinite loop. That will kill the whole app.<br />
Use the QTimer. Then no loop is needed. Timer is the loop so to speak.</p>
]]></description><link>https://forum.qt.io/post/522301</link><guid isPermaLink="true">https://forum.qt.io/post/522301</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Wed, 10 Apr 2019 10:25:22 GMT</pubDate></item><item><title><![CDATA[Reply to Updating label content every 2 minutes on Wed, 10 Apr 2019 10:21:43 GMT]]></title><description><![CDATA[<p dir="auto">So, in the mainwindow i have put something like:</p>
<p dir="auto">while(1==1){<br />
-&gt; i call on_butttom_clicked<br />
-&gt; i define the timer in 2 minuts</p>
<p dir="auto">} //kind of infinite while</p>
<p dir="auto">?</p>
]]></description><link>https://forum.qt.io/post/522300</link><guid isPermaLink="true">https://forum.qt.io/post/522300</guid><dc:creator><![CDATA[nadales56]]></dc:creator><pubDate>Wed, 10 Apr 2019 10:21:43 GMT</pubDate></item><item><title><![CDATA[Reply to Updating label content every 2 minutes on Wed, 10 Apr 2019 10:16:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nadales56">@<bdi>nadales56</bdi></a><br />
Hi<br />
yes, setting up timer will call your slot after the time you set.<br />
In that way, the timer can do what button does automatically.</p>
]]></description><link>https://forum.qt.io/post/522298</link><guid isPermaLink="true">https://forum.qt.io/post/522298</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Wed, 10 Apr 2019 10:16:29 GMT</pubDate></item><item><title><![CDATA[Reply to Updating label content every 2 minutes on Wed, 10 Apr 2019 10:08:29 GMT]]></title><description><![CDATA[<p dir="auto">Thank you JonB!<br />
I have just make the text file content in the label!! =)</p>
<p dir="auto">I have some doubts about where or when should i use qtimer. I mean, first i clicked the button, so the information appear in the label, then i have to use qtimer to update the text automatically without clicking the buttom?</p>
]]></description><link>https://forum.qt.io/post/522293</link><guid isPermaLink="true">https://forum.qt.io/post/522293</guid><dc:creator><![CDATA[nadales56]]></dc:creator><pubDate>Wed, 10 Apr 2019 10:08:29 GMT</pubDate></item><item><title><![CDATA[Reply to Updating label content every 2 minutes on Wed, 10 Apr 2019 09:50:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nadales56">@<bdi>nadales56</bdi></a><br />
You will use <a href="https://doc.qt.io/qt-5/qtimer.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qtimer.html</a> to set up a timer that repeatedly ticks every two minutes, and have its slot action update the text on the label.  You will use <a href="https://doc.qt.io/qt-5/qiodevice.html#readAll" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qiodevice.html#readAll</a> to read the file's content.  See how you go from there.</p>
<p dir="auto">If you later wish to be "clever", you might use <a href="https://doc.qt.io/qt-5/qfilesystemwatcher.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qfilesystemwatcher.html</a> to watch the file for changes to its content and only re-read at that point, rather than every two minutes regardless.</p>
]]></description><link>https://forum.qt.io/post/522283</link><guid isPermaLink="true">https://forum.qt.io/post/522283</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 10 Apr 2019 09:50:16 GMT</pubDate></item></channel></rss>