<?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[Emit Signal When CheckState is Changed in the Model]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">We add checkboxes for a spesific column in a QTableView via changing the setData() and data() methods of the model with CheckStateRole. We did not create QCheckBox. Checkboxes are created automatically with the help of the Qt::CheckStateRole and Qt::ItemIsUserCheckable  flag. (This is the way wanted from us.)</p>
<p dir="auto">When a checkbox is checked/unchecked by mouseclick we want to emit a signal. However, we couldnt do that. We cannot emit our own signal after dataChanged() signal, which can lead to emit some singals more than once.</p>
<p dir="auto">Is there any way to do it?</p>
]]></description><link>https://forum.qt.io/topic/116989/emit-signal-when-checkstate-is-changed-in-the-model</link><generator>RSS for Node</generator><lastBuildDate>Fri, 31 Jul 2026 10:24:27 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/116989.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 14 Jul 2020 06:52:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Thu, 06 Aug 2020 18:09:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dzcode">@<bdi>DzCode</bdi></a> said in <a href="/post/610629">Emit Signal When CheckState is Changed in the Model</a>:</p>
<blockquote>
<p dir="auto">I did it.</p>
</blockquote>
<p dir="auto">does it mean your issue is solved? if so please don't forget to mark your post as such!</p>
]]></description><link>https://forum.qt.io/post/610966</link><guid isPermaLink="true">https://forum.qt.io/post/610966</guid><dc:creator><![CDATA[Pablo J. Rogina]]></dc:creator><pubDate>Thu, 06 Aug 2020 18:09:43 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Wed, 05 Aug 2020 08:29:16 GMT]]></title><description><![CDATA[<p dir="auto">Now, I am checking the position of mouse and controlling the table item in mouse press and mouse release. Via holding a state as a private member variable, I did it.</p>
]]></description><link>https://forum.qt.io/post/610629</link><guid isPermaLink="true">https://forum.qt.io/post/610629</guid><dc:creator><![CDATA[DzCode]]></dc:creator><pubDate>Wed, 05 Aug 2020 08:29:16 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 13:29:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dzcode">@<bdi>DzCode</bdi></a><br />
Hi<br />
I would assume that on mouseRelease the data would still be the same.<br />
But since its a bool checked/not checked could you not emit signal anyway<br />
with just the opposite of what it is ? so if unchecked send checked  and reverse.<br />
It will first be changed after but you can get a signal before dataChanged is called ?</p>
]]></description><link>https://forum.qt.io/post/606710</link><guid isPermaLink="true">https://forum.qt.io/post/606710</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Tue, 14 Jul 2020 13:29:18 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 13:04:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> Actually, I tried it with mousepress and mouserelease and couldnt do it. In press event I hold the previous data and in release I look at the current data. I checked for the changes but not worked</p>
]]></description><link>https://forum.qt.io/post/606708</link><guid isPermaLink="true">https://forum.qt.io/post/606708</guid><dc:creator><![CDATA[DzCode]]></dc:creator><pubDate>Tue, 14 Jul 2020 13:04:53 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 08:58:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dzcode">@<bdi>DzCode</bdi></a><br />
Well you test if you click in a cell but the "checkbox" is just drawn so it cant emit any mouse events by itself.<br />
Overwrite view's mousePress . remember to call base class after<br />
The read the model if its currently checked or unchecked and then assume the opposite<br />
when model updates. Then it might be possible to send signal before model is actually updated.</p>
]]></description><link>https://forum.qt.io/post/606632</link><guid isPermaLink="true">https://forum.qt.io/post/606632</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Tue, 14 Jul 2020 08:58:17 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 08:34:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> custom model implemented from QAbstractItemModel is used in the project.<br />
Is there any way to do it with mouseevents?</p>
]]></description><link>https://forum.qt.io/post/606630</link><guid isPermaLink="true">https://forum.qt.io/post/606630</guid><dc:creator><![CDATA[DzCode]]></dc:creator><pubDate>Tue, 14 Jul 2020 08:34:38 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 08:29:23 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
My friend <a class="plugin-mentions-user plugin-mentions-a" href="/user/ratzz">@<bdi>Ratzz</bdi></a>  suggested to use a delegate.<br />
You could the overwrite setData, check if item check/unchecked.<br />
and emit signal there. it would then come before the model handle it.</p>
]]></description><link>https://forum.qt.io/post/606629</link><guid isPermaLink="true">https://forum.qt.io/post/606629</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Tue, 14 Jul 2020 08:29:23 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 07:56:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dzcode">@<bdi>DzCode</bdi></a><br />
I assume its not a std item model so we cant use<br />
<a href="https://doc.qt.io/qt-5/qstandarditemmodel.html#itemChanged" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qstandarditemmodel.html#itemChanged</a><br />
so all we have is setData.</p>
]]></description><link>https://forum.qt.io/post/606622</link><guid isPermaLink="true">https://forum.qt.io/post/606622</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Tue, 14 Jul 2020 07:56:35 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 07:47:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> the main problem is how I can detect that the checkbox is clicked by mouse or not? How can I get it</p>
]]></description><link>https://forum.qt.io/post/606616</link><guid isPermaLink="true">https://forum.qt.io/post/606616</guid><dc:creator><![CDATA[DzCode]]></dc:creator><pubDate>Tue, 14 Jul 2020 07:47:20 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 07:38:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dzcode">@<bdi>DzCode</bdi></a><br />
Hi<br />
You can call a slot without a signal, it just a normal member function.<br />
So you could block others and directly call the slot.<br />
If that would help ?</p>
]]></description><link>https://forum.qt.io/post/606614</link><guid isPermaLink="true">https://forum.qt.io/post/606614</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Tue, 14 Jul 2020 07:38:03 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 07:33:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> I will emit the same signal.</p>
<p dir="auto">For example for clicking "space" , I am emitting a signal that emit only once for multiple checking of all chekboxes. It emits after space key pressed. I also want to emit the same signal for only clicking checkbox. So that your solution is not suitable for me</p>
]]></description><link>https://forum.qt.io/post/606612</link><guid isPermaLink="true">https://forum.qt.io/post/606612</guid><dc:creator><![CDATA[DzCode]]></dc:creator><pubDate>Tue, 14 Jul 2020 07:33:29 GMT</pubDate></item><item><title><![CDATA[Reply to Emit Signal When CheckState is Changed in the Model on Tue, 14 Jul 2020 07:16:49 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
Im not sure why a new signal would affect your current handling.<br />
If you in setData emit a new signal , could you not just do what needs to be done in that slot<br />
without triggering other signals ?</p>
<p dir="auto">You could also do</p>
<pre><code>view-&gt;blockSignals(true);
   ...what..ever
view-&gt;blockSignals(false);
</code></pre>
<p dir="auto">in that slot to prevent triggering stuff.</p>
<p dir="auto">if you try this way, do note<br />
<a href="https://doc.qt.io/qt-5/qsignalblocker.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qsignalblocker.html</a></p>
<p dir="auto">Which is safer than calling blockSignals</p>
]]></description><link>https://forum.qt.io/post/606605</link><guid isPermaLink="true">https://forum.qt.io/post/606605</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Tue, 14 Jul 2020 07:16:49 GMT</pubDate></item></channel></rss>