<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Qt Centre Forum - Qt Programming</title>
		<link>https://www.qtcentre.org/</link>
		<description>General more advanced Qt programming issues.</description>
		<language>en</language>
		<lastBuildDate>Sat, 07 Mar 2026 06:15:43 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>15</ttl>
		<image>
			<url>https://qtcentre.org/images/misc/rss.png</url>
			<title>Qt Centre Forum - Qt Programming</title>
			<link>https://www.qtcentre.org/</link>
		</image>
		<item>
			<title>QTimer Not Triggering Slot in Qt Application</title>
			<link>https://qtcentre.org/threads/72289-QTimer-Not-Triggering-Slot-in-Qt-Application?goto=newpost</link>
			<pubDate>Tue, 03 Mar 2026 07:05:43 GMT</pubDate>
			<description>Hi everyone, 
 
I’m having trouble with a `QTimer` that doesn’t seem to trigger its slot. The timer starts without errors, but the timeout function...</description>
			<content:encoded><![CDATA[<div>Hi everyone,<br />
<br />
I’m having trouble with a `QTimer` that doesn’t seem to trigger its slot. The timer starts without errors, but the timeout function is never called.<br />
<br />
Here is a simplified version of my code:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"><pre class="qt" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339900;">#include &lt;QApplication&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339900;">#include &lt;QMainWindow&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339900;">#include &lt;QTimer&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339900;">#include &lt;QDebug&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">class MainWindow <span style="color: #000000;">:</span> <span style="color: #0000ff;">public</span> <a href="http://qt-project.org/doc/qt-4.8/qmainwindow.html"><span style="">QMainWindow</span></a></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="font-weight: bold;">Q_OBJECT</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">public</span><span style="color: #000000;">:</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    MainWindow<span style="color: #000000;">&#40;</span><a href="http://qt-project.org/doc/qt-4.8/qwidget.html"><span style="">QWidget</span></a> <span style="color: #000000;">*</span>parent <span style="color: #000000;">=</span> nullptr<span style="color: #000000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #000000;">:</span> <a href="http://qt-project.org/doc/qt-4.8/qmainwindow.html"><span style="">QMainWindow</span></a><span style="color: #000000;">&#40;</span>parent<span style="color: #000000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #000000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <a href="http://qt-project.org/doc/qt-4.8/qtimer.html"><span style="">QTimer</span></a> <span style="color: #000000;">*</span>timer <span style="color: #000000;">=</span> <span style="color: #009900;">new</span> <a href="http://qt-project.org/doc/qt-4.8/qtimer.html"><span style="">QTimer</span></a><span style="color: #000000;">&#40;</span><span style="color: #009900;">this</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        <span style="color: #0000ff;">connect</span><span style="color: #000000;">&#40;</span>timer, <span style="color: #000000;">&amp;</span>QTimer<span style="color: #000000;">::</span><span style="color: #009900;">timeout</span>, <span style="color: #009900;">this</span>, <span style="color: #000000;">&amp;</span>MainWindow<span style="color: #000000;">::</span><span style="color: #009900;">onTimeout</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        timer<span style="color: #000000;">-</span>&gt;start<span style="color: #000000;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #000000;">&#41;</span>;  <span style="color: #ff0000;">// 1 second</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #000000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">slots</span><span style="color: #000000;">:</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #0000ff;">void</span> onTimeout<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #000000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">        qDebug<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> &lt;&lt; <span style="color: #666666;">&quot;Timer triggered&quot;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #000000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#125;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">int</span> main<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000000;">*</span>argv<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <a href="http://qt-project.org/doc/qt-4.8/qapplication.html"><span style="">QApplication</span></a> a<span style="color: #000000;">&#40;</span>argc, argv<span style="color: #000000;">&#41;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    MainWindow w;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    w.<span style="color: #009900;">show</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">    <span style="color: #0000ff;">return</span> a.<span style="color: #009900;">exec</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#125;</span></div></li></ol></pre></code><hr />
</div><br />
The application runs fine, but &quot;Timer triggered&quot; never appears in the console.<br />
Am I missing something related to the event loop or object lifetime?<br />
Is there something wrong with how I’m creating or connecting the timer?</div>

]]></content:encoded>
			<category domain="https://qtcentre.org/forums/2-Qt-Programming">Qt Programming</category>
			<dc:creator>skylerclooney</dc:creator>
			<guid isPermaLink="true">https://qtcentre.org/threads/72289-QTimer-Not-Triggering-Slot-in-Qt-Application</guid>
		</item>
	</channel>
</rss>
