<?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[QVariant convert to QBrush]]></title><description><![CDATA[<p dir="auto">I am working with a QTreeview.<br />
Using:<br />
index_data = treeview.model.data(index, QT::ForegroundRole)<br />
index_data.type()<br />
&gt; 66 -&gt; QBrush<br />
index_data.canConvert(66)</p>
<blockquote>
<p dir="auto">1<br />
index_data.convert(66)<br />
1<br />
So all indications are that the QVariant was converted to QBrush,<br />
however I am unable to call any QBrush functions on idex_data.<br />
I am doing all of this in Squish</p>
</blockquote>
<p dir="auto">I am ultimately looking for the color of text in the index.</p>
]]></description><link>https://forum.qt.io/topic/54863/qvariant-convert-to-qbrush</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 02:56:17 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/54863.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 03 Jun 2015 13:10:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QVariant convert to QBrush on Wed, 03 Jun 2015 13:44:19 GMT]]></title><description><![CDATA[<p dir="auto">Unfortunately Squish does not allow me to use the same syntax that you are using.<br />
I tried multiple variations of your code all give me &lt;type 'exceptions.AttributeError'&gt;.<br />
I am contacting them. Thanks for the help.</p>
]]></description><link>https://forum.qt.io/post/276571</link><guid isPermaLink="true">https://forum.qt.io/post/276571</guid><dc:creator><![CDATA[ctoverend]]></dc:creator><pubDate>Wed, 03 Jun 2015 13:44:19 GMT</pubDate></item><item><title><![CDATA[Reply to QVariant convert to QBrush on Wed, 03 Jun 2015 13:33:09 GMT]]></title><description><![CDATA[<p dir="auto"><code>QBrush brush = index_data.value&lt;QBrush&gt;();</code></p>
<p dir="auto">There you have your QBrush object you want to test</p>
]]></description><link>https://forum.qt.io/post/276570</link><guid isPermaLink="true">https://forum.qt.io/post/276570</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 03 Jun 2015 13:33:09 GMT</pubDate></item><item><title><![CDATA[Reply to QVariant convert to QBrush on Wed, 03 Jun 2015 13:29:14 GMT]]></title><description><![CDATA[<p dir="auto">The color of the text is already set. I am testing that the color is correct.<br />
When I convert the QVariant to a QBrush I expect that I can call color()<br />
and verify that it was set properly. However when I convert the Qvariant to QBrush the functions available to me are those of the QVariant not QBrush. Is there a better way to get text color from an QModelIndex?</p>
]]></description><link>https://forum.qt.io/post/276569</link><guid isPermaLink="true">https://forum.qt.io/post/276569</guid><dc:creator><![CDATA[ctoverend]]></dc:creator><pubDate>Wed, 03 Jun 2015 13:29:14 GMT</pubDate></item><item><title><![CDATA[Reply to QVariant convert to QBrush on Wed, 03 Jun 2015 13:22:01 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">you should rather use</p>
<p dir="auto"><code>index_data.canConvert&lt;QBrush&gt;()</code></p>
<p dir="auto">then</p>
<pre><code>QBrush brush = index_data.value&lt;QBrush&gt;();
//modify brush
treeview-&gt;model()-&gt;setData(index, brush, Qt::ForegroundRole);
</code></pre>
<p dir="auto">Hope it helps</p>
]]></description><link>https://forum.qt.io/post/276566</link><guid isPermaLink="true">https://forum.qt.io/post/276566</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 03 Jun 2015 13:22:01 GMT</pubDate></item></channel></rss>