<?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[What palette role&#x2F;attribute sets the line color of QFrame &quot;setLineWidth&quot; ?]]></title><description><![CDATA[<p dir="auto">Hello -<br />
I am looking to change the color of the line drawn around the edge of a QFrame using this code:</p>
<p dir="auto">QFrame* frameA = new QFrame(centralWidget)<br />
frameA-&gt;setFrameShape(QFrame::Box);<br />
frameA-&gt;setFrameShadow(QFrame::Sunken);<br />
frameA-&gt;setLineWidth(2);<br />
frameA-&gt;setMidLineWidth(4);</p>
<p dir="auto">If I do this:<br />
QBrush brush1(QColor(127, 127, 127, 255));<br />
brush1.setStyle(Qt::SolidPattern);<br />
palette.setBrush(QPalette::Active, QPalette::Mid, brush1);</p>
<p dir="auto">Then the line drawn for "setMindLineWidth"  is grey, as expected.<br />
But the line drawn from 'setLineWidth(2)'  is always white.  How do I change that color?</p>
<p dir="auto">And yes, I have don  this:</p>
<pre><code>QBrush brush3(QColor(255, 0, 0 255));
brush.setStyle(Qt::SolidPattern);
palette.setBrush(QPalette::Active, QPalette::WindowText, brush3);
palette.setBrush(QPalette::Active, QPalette::Text, brush3);
</code></pre>
<p dir="auto">I am using Qt5  and I do <em>NOT</em> want to use style sheet.<br />
Operating system is Linux / Xorg</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.qt.io/topic/145850/what-palette-role-attribute-sets-the-line-color-of-qframe-setlinewidth</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 10:31:06 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/145850.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 18 Jun 2023 13:42:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to What palette role&#x2F;attribute sets the line color of QFrame &quot;setLineWidth&quot; ? on Sun, 18 Jun 2023 16:06:54 GMT]]></title><description><![CDATA[<p dir="auto">@Abderrahmene_Rayene said in <a href="/post/761802">What palette role/attribute sets the line color of QFrame "setLineWidth" ?</a>:</p>
<blockquote>
<p dir="auto">palette.setBrush(QPalette::Active, QPalette::Light, brush1);</p>
</blockquote>
<p dir="auto">Yes, thank you.<br />
So the answer to my question is</p>
<p dir="auto">alette.setBrush(QPalette::Active, QPalette::Light, brush1);<br />
palette.setBrush(QPalette::Active, QPalette::Dark, brush1);</p>
]]></description><link>https://forum.qt.io/post/761803</link><guid isPermaLink="true">https://forum.qt.io/post/761803</guid><dc:creator><![CDATA[edmh]]></dc:creator><pubDate>Sun, 18 Jun 2023 16:06:54 GMT</pubDate></item><item><title><![CDATA[Reply to What palette role&#x2F;attribute sets the line color of QFrame &quot;setLineWidth&quot; ? on Sun, 18 Jun 2023 15:55:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm not sure I understand (a screenshot of your current result would be helpful), but I'm guessing the shadow color is what you mean.</p>
<p dir="auto">From <a href="https://doc.qt.io/qt-6/qframe.html#Shadow-enum" target="_blank" rel="noopener noreferrer nofollow ugc">QFrame documentation</a>:</p>
<blockquote>
<p dir="auto"><strong>QFrame::Sunken :</strong> the frame and contents appear sunken; draws a 3D sunken line using the light and dark colors of the current color group</p>
</blockquote>
<p dir="auto">So try this:</p>
<pre><code>QFrame* frameA = new QFrame();
frameA-&gt;setFrameShape(QFrame::Box);
frameA-&gt;setFrameShadow(QFrame::Sunken);
frameA-&gt;setLineWidth(2);
frameA-&gt;setMidLineWidth(4);

QBrush brush1(QColor(127, 127, 127, 255));
brush1.setStyle(Qt::SolidPattern);

QPalette palette=frameA-&gt;palette();
//shadow color, dark and light palette roles
palette.setBrush(QPalette::Active, QPalette::Light, brush1);
palette.setBrush(QPalette::Active, QPalette::Dark, brush1);

//mid line color
palette.setBrush(QPalette::Active, QPalette::Mid, brush1);
frameA-&gt;setPalette(palette);

frameA-&gt;show();
</code></pre>
<p dir="auto">Is this the result you're looking for?</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/21c8d789-9bce-4960-8ad6-4c335d7c7363.png" alt="framecolor.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/761802</link><guid isPermaLink="true">https://forum.qt.io/post/761802</guid><dc:creator><![CDATA[CPPUIX]]></dc:creator><pubDate>Sun, 18 Jun 2023 15:55:59 GMT</pubDate></item></channel></rss>