<?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[Setting the background color of a QFrame object ignored]]></title><description><![CDATA[<p dir="auto">Hi.</p>
<p dir="auto">I'm trying to set the background color of a QFrame object.<br />
If I do it from Qt Creator it works fine (see below), if I do it in another project's code the setting is ignored.</p>
<pre><code>QPalette pal;
pal.setColor( QPalette::Base, Qt::black );
framePanel-&gt;setPalette(pal);
</code></pre>
<p dir="auto">I tried a little bit of everything but it was all ignored, does anyone have a solution, any ideas?<br />
<img src="https://ddgobkiprc33d.cloudfront.net/d6456ce3-3a9c-4db4-b5a4-287552bbbfaf.png" alt="Screenshot_20230528_125722.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/145420/setting-the-background-color-of-a-qframe-object-ignored</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 09:18:32 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/145420.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 28 May 2023 11:12:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Setting the background color of a QFrame object ignored on Sun, 28 May 2023 14:20:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> I was lucky, it stopped working in Qt Creator as well 🤣 .<br />
And having a minimum of more experience I went to the bottom.</p>
<p dir="auto">Apparently in Qt Creator it worked by mistake, it was enough to mess around for a minimum and it didn't work anymore.</p>
<p dir="auto">The solution</p>
<pre><code>framePanel-&gt;setAutoFillBackground( true );
</code></pre>
]]></description><link>https://forum.qt.io/post/759656</link><guid isPermaLink="true">https://forum.qt.io/post/759656</guid><dc:creator><![CDATA[giusdbg]]></dc:creator><pubDate>Sun, 28 May 2023 14:20:34 GMT</pubDate></item><item><title><![CDATA[Reply to Setting the background color of a QFrame object ignored on Sun, 28 May 2023 12:41:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> It will be difficult to do this, because the other application is kde.</p>
<p dir="auto">It occurs to me that I've ruled out your assumption, but it could be some part of kde doing this.</p>
]]></description><link>https://forum.qt.io/post/759653</link><guid isPermaLink="true">https://forum.qt.io/post/759653</guid><dc:creator><![CDATA[giusdbg]]></dc:creator><pubDate>Sun, 28 May 2023 12:41:55 GMT</pubDate></item><item><title><![CDATA[Reply to Setting the background color of a QFrame object ignored on Sun, 28 May 2023 12:04:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/giusdbg">@<bdi>giusdbg</bdi></a><br />
Then you will have to track that down.  usual procedure is to try what you have in a standalone, tiny program, then if it works find out how yours differs.</p>
]]></description><link>https://forum.qt.io/post/759652</link><guid isPermaLink="true">https://forum.qt.io/post/759652</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Sun, 28 May 2023 12:04:04 GMT</pubDate></item><item><title><![CDATA[Reply to Setting the background color of a QFrame object ignored on Sun, 28 May 2023 12:00:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> It's a bit of a complex project and I don't fully master it, but I'd say definitely not.</p>
<p dir="auto">A few more pieces of code, if that helps.<br />
My feeling is that the QFrame object is in transparent mode.</p>
<pre><code>    framePanel = new QFrame( this );
    framePanel-&gt;setMinimumSize( QSize( 64, 64 ) );
    framePanel-&gt;setMaximumSize( QSize( 64, 64 ) );
....................
    framePanel-&gt;setPalette( pal );
    framePanel-&gt;setFrameShape( QFrame::Panel );
    framePanel-&gt;setFrameShadow( QFrame::Raised );

    labelTitle = new QLabel( framePanel );
    labelTitle-&gt;setGeometry( QRect( 8, 40, 50, 20 ) );
    QFont labelTitle_font(  labelTitle-&gt;font() );
    labelTitle_font.setPointSize( 7 );
    labelTitle-&gt;setFont( labelTitle_font ); 
    labelTitle-&gt;setAlignment( Qt::AlignCenter );

    labelValue = new QLabel( framePanel );
    labelValue-&gt;setGeometry( QRect( 7, 16, 50, 20 ) );
    labelValue-&gt;setAlignment( Qt::AlignCenter );

    PaletteCfgDesignLayout-&gt;addWidget( framePanel, 0, 0, 0, 1 );

</code></pre>
]]></description><link>https://forum.qt.io/post/759650</link><guid isPermaLink="true">https://forum.qt.io/post/759650</guid><dc:creator><![CDATA[giusdbg]]></dc:creator><pubDate>Sun, 28 May 2023 12:00:51 GMT</pubDate></item><item><title><![CDATA[Reply to Setting the background color of a QFrame object ignored on Sun, 28 May 2023 11:30:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/giusdbg">@<bdi>giusdbg</bdi></a><br />
Does the "other project" use stylesheets?</p>
]]></description><link>https://forum.qt.io/post/759648</link><guid isPermaLink="true">https://forum.qt.io/post/759648</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Sun, 28 May 2023 11:30:27 GMT</pubDate></item></channel></rss>