<?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[Checkable Qtreeview.]]></title><description><![CDATA[<p dir="auto">How ca I implement a checkable treeview?</p>
]]></description><link>https://forum.qt.io/topic/80256/checkable-qtreeview</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 18:23:46 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/80256.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 13 Jun 2017 05:31:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Checkable Qtreeview. on Tue, 13 Jun 2017 14:37:31 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;QApplication&gt;
#include &lt;QTreeWidget&gt;

int main(int argc, char *argv[])
{

    QApplication app(argc,argv);
    QTreeWidget w;
    auto item1 = new QTreeWidgetItem(QStringList("0,0"));
    item1-&gt;setFlags(item1-&gt;flags() | Qt::ItemIsUserCheckable);
    item1-&gt;setData(0,Qt::CheckStateRole,Qt::Unchecked);
    w.addTopLevelItem(item1);
    auto item2 = new QTreeWidgetItem(QStringList("1,0"));
    item2-&gt;setFlags(item2-&gt;flags() | Qt::ItemIsUserCheckable);
    item1-&gt;setData(0,Qt::CheckStateRole,Qt::Unchecked);
    w.addTopLevelItem(item2);
    w.show();
    return app.exec();
}
</code></pre>
<p dir="auto">I use QTreeWidget (which derives from QTreeView) for convenience here but you can use whatever combination of model/view you prefer</p>
]]></description><link>https://forum.qt.io/post/399224</link><guid isPermaLink="true">https://forum.qt.io/post/399224</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Tue, 13 Jun 2017 14:37:31 GMT</pubDate></item><item><title><![CDATA[Reply to Checkable Qtreeview. on Tue, 13 Jun 2017 11:00:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vronin">@<bdi>VRonin</bdi></a> could you please show me some example ?</p>
]]></description><link>https://forum.qt.io/post/399207</link><guid isPermaLink="true">https://forum.qt.io/post/399207</guid><dc:creator><![CDATA[BinuJanardhanan]]></dc:creator><pubDate>Tue, 13 Jun 2017 11:00:33 GMT</pubDate></item><item><title><![CDATA[Reply to Checkable Qtreeview. on Tue, 13 Jun 2017 06:57:45 GMT]]></title><description><![CDATA[<p dir="auto">Just attach a model with the <code>Qt::ItemIsUserCheckable</code> <a href="http://doc.qt.io/qt-5/qabstractitemmodel.html#flags" target="_blank" rel="noopener noreferrer nofollow ugc">flag</a> set for the indexes you want to be checkable</p>
]]></description><link>https://forum.qt.io/post/399130</link><guid isPermaLink="true">https://forum.qt.io/post/399130</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Tue, 13 Jun 2017 06:57:45 GMT</pubDate></item></channel></rss>