<?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[How to timeouts a lot of objects]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I receive a lot of events from a class. This is the slot called:</p>
<p dir="auto">@<br />
void caught(int idx);<br />
@</p>
<p dir="auto">When executed it highlights the row number 'idx' on a QTableView.<br />
I want to clear each highlight after, say, 250 ms.<br />
It would be EXTREMELY easy if I can write:</p>
<p dir="auto">@<br />
void caught(int idx)<br />
{<br />
model-&gt;highlightRow(idx);<br />
QTimer::singleShot(250, model, SLOT(clearHighlightRow(idx)));<br />
}<br />
@</p>
<p dir="auto">but for some reasons you cannot call a SLOT with parameters :-(</p>
<p dir="auto">What is the recommended way to achieve the same behavior?</p>
]]></description><link>https://forum.qt.io/topic/50247/how-to-timeouts-a-lot-of-objects</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 09:40:17 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/50247.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 17 Jan 2015 21:31:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to timeouts a lot of objects on Sun, 18 Jan 2015 13:41:40 GMT]]></title><description><![CDATA[<p dir="auto">Works in all of Qt 5.x as long as you have a compiler that support C++/11 or up.</p>
<p dir="auto">So, simply write:<br />
@<br />
void caught(int idx)<br />
{<br />
model-&gt;highlightRow(idx);<br />
QTimer::singleShot(250, <a>model, idx</a> {model-&gt;clearHighlight(idx);});<br />
}<br />
@</p>
<p dir="auto">One thing to take care off: this will cause a crash if model is destructed while there is still a timer running. You can solve that using a QPointer&lt;MyModel&gt; instead of passing a plain pointer to the closure.</p>
]]></description><link>https://forum.qt.io/post/258054</link><guid isPermaLink="true">https://forum.qt.io/post/258054</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Sun, 18 Jan 2015 13:41:40 GMT</pubDate></item><item><title><![CDATA[Reply to How to timeouts a lot of objects on Sun, 18 Jan 2015 10:59:34 GMT]]></title><description><![CDATA[<p dir="auto">Unfortunately I'm still with Qt5.3.</p>
]]></description><link>https://forum.qt.io/post/258042</link><guid isPermaLink="true">https://forum.qt.io/post/258042</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sun, 18 Jan 2015 10:59:34 GMT</pubDate></item><item><title><![CDATA[Reply to How to timeouts a lot of objects on Sat, 17 Jan 2015 22:41:42 GMT]]></title><description><![CDATA[<p dir="auto">If you are using Qt 5.4 and a compiler that supports C++11, you can call QTimer::singleShot() with a lambda function.</p>
]]></description><link>https://forum.qt.io/post/258007</link><guid isPermaLink="true">https://forum.qt.io/post/258007</guid><dc:creator><![CDATA[ckakman]]></dc:creator><pubDate>Sat, 17 Jan 2015 22:41:42 GMT</pubDate></item><item><title><![CDATA[Reply to How to timeouts a lot of objects on Sat, 17 Jan 2015 21:49:06 GMT]]></title><description><![CDATA[<p dir="auto">I found an ugly workaround. In the caught SLOT I enqueue idx and call the singleShot method.<br />
In its own SLOT I dequeue the idx and clear the highlight.</p>
<p dir="auto">It works, but I don't like it at all.</p>
]]></description><link>https://forum.qt.io/post/258000</link><guid isPermaLink="true">https://forum.qt.io/post/258000</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sat, 17 Jan 2015 21:49:06 GMT</pubDate></item></channel></rss>