<?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 add the check box with item, and Checkbox should check by the user.]]></title><description><![CDATA[<pre><code>  auto hwList = new QListView();

  class HardwareProxyModel : public  QSortFilterProxyModel { 
         // Do some Filtering 
    }
    
    auto hwListProxyModel = new HardwareProxyModel;
    hwListProxyModel-&gt;setSourceModel(new QStandardItemModel(0, 0));
    hwList-&gt;setModel(hwListProxyModel);
</code></pre>
<p dir="auto">I access model</p>
<pre><code>  auto model = hwListProxyModel-&gt;sourceModel();
</code></pre>
<p dir="auto">and Add the item in model</p>
<pre><code> auto count = model-&gt;rowCount();
 model-&gt;insertRow(count);
 auto index = model-&gt;index(count, 0);
 model-&gt;setData(index, it-&gt;name, Qt::DisplayRole);
 model-&gt;setData(index, it-&gt;channelAmount, Qt::UserRole);
</code></pre>
<p dir="auto">I can add the Item with check box with help of     model-&gt;setData(index, Qt::Unchecked, Qt::CheckStateRole);</p>
<p dir="auto">I wanted to add the Item with check box, and that check box should check by user. In above logic, I can add the check box, but user is not able to do check the item.</p>
<p dir="auto">What Should I have to do if I want to give access to user for check mark?</p>
]]></description><link>https://forum.qt.io/topic/90634/how-to-add-the-check-box-with-item-and-checkbox-should-check-by-the-user</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 23:00:38 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/90634.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 11 May 2018 17:31:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to add the check box with item, and Checkbox should check by the user. on Fri, 11 May 2018 20:09:07 GMT]]></title><description><![CDATA[<p dir="auto">Thank you <a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a>  and <a class="plugin-mentions-user plugin-mentions-a" href="/user/christian">@<bdi>Christian</bdi></a> for answer.  I am able to make user Checkable.</p>
<p dir="auto">class CustomListModel : public QStandardItemModel {<br />
public:<br />
Qt::ItemFlags CustomListModel::flags(const QModelIndex &amp; index) const {<br />
Qt::ItemFlags defaultFlags = QStandardItemModel::flags(index);<br />
if (index.isValid()) {<br />
return defaultFlags | Qt::ItemIsUserCheckable;<br />
}<br />
return defaultFlags;<br />
}</p>
<pre><code>CustomListModel(const int row, const int coloumn) :
	QStandardItemModel(row, coloumn) {

}
</code></pre>
<p dir="auto">};</p>
<p dir="auto">and modification.<br />
hwListProxyModel-&gt;setSourceModel(new CustomListModel (0, 0));</p>
]]></description><link>https://forum.qt.io/post/457763</link><guid isPermaLink="true">https://forum.qt.io/post/457763</guid><dc:creator><![CDATA[Yash001]]></dc:creator><pubDate>Fri, 11 May 2018 20:09:07 GMT</pubDate></item><item><title><![CDATA[Reply to How to add the check box with item, and Checkbox should check by the user. on Fri, 11 May 2018 19:09:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yash001">@<bdi>Yash001</bdi></a><br />
Hi<br />
yes there is also a method<br />
<a href="http://doc.qt.io/qt-5/qabstractitemmodel.html#flags" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qabstractitemmodel.html#flags</a></p>
]]></description><link>https://forum.qt.io/post/457756</link><guid isPermaLink="true">https://forum.qt.io/post/457756</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Fri, 11 May 2018 19:09:59 GMT</pubDate></item><item><title><![CDATA[Reply to How to add the check box with item, and Checkbox should check by the user. on Fri, 11 May 2018 19:08:07 GMT]]></title><description><![CDATA[<p dir="auto">Thank Christian, Yes If I just use the QStandardItemModel then i can set the Flag and Make it user check able  but here I am using With QSortFilterProxyModel. that's why,  I am not getting setflag property and setItem Property.</p>
<p dir="auto">Is It any way for setting flag of the model item, if the model is inherit fromQSortFilterProxyModel?</p>
]]></description><link>https://forum.qt.io/post/457755</link><guid isPermaLink="true">https://forum.qt.io/post/457755</guid><dc:creator><![CDATA[Yash001]]></dc:creator><pubDate>Fri, 11 May 2018 19:08:07 GMT</pubDate></item><item><title><![CDATA[Reply to How to add the check box with item, and Checkbox should check by the user. on Fri, 11 May 2018 18:28:54 GMT]]></title><description><![CDATA[<p dir="auto">You have to make the items user checkable:<br />
<a href="http://doc.qt.io/qt-5/qstandarditem.html#setFlags" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qstandarditem.html#setFlags</a><br />
<a href="http://doc.qt.io/qt-5/qt.html#ItemFlag-enum" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qt.html#ItemFlag-enum</a></p>
]]></description><link>https://forum.qt.io/post/457752</link><guid isPermaLink="true">https://forum.qt.io/post/457752</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 11 May 2018 18:28:54 GMT</pubDate></item></channel></rss>