<?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 combine stylesheets and custom widget painting?]]></title><description><![CDATA[<p dir="auto">We've got a method to draw text in the QTabBar bold, because there's no provided function for it. However the bar can no longer be customised with a stylesheet, which means the entire application is themable <em>except</em> for the tabbar - and this really stands out!</p>
<p dir="auto">How can the two be merged?</p>
<p dir="auto">Our custom painting method for reference:</p>
<pre><code class="language-cpp">void TStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
    if (element == QStyle::CE_TabBarTab) {
        QString tabName = mpTabBar-&gt;tabData(mpTabBar-&gt;tabAt(option-&gt;rect.center())).toString();
        QFont font = widget-&gt;font();
        bool isStyleChanged = false;
        if (mBoldTabsSet.contains(tabName)||mItalicTabsSet.contains(tabName)||mUnderlineTabsSet.contains(tabName)) {
            painter-&gt;save();
            font.setBold(mBoldTabsSet.contains(tabName));
            font.setItalic(mItalicTabsSet.contains(tabName));
            font.setUnderline(mUnderlineTabsSet.contains(tabName));
            isStyleChanged = true;
            painter-&gt;setFont(font);
        }

        QProxyStyle::drawControl(element, option, painter, widget);

        if (isStyleChanged) {
            painter-&gt;restore();
        }

    } else {
        QProxyStyle::drawControl(element, option, painter, widget);
    }
}
</code></pre>
]]></description><link>https://forum.qt.io/topic/106941/how-to-combine-stylesheets-and-custom-widget-painting</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 17:51:37 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/106941.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 16 Sep 2019 20:30:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to combine stylesheets and custom widget painting? on Tue, 17 Sep 2019 04:57:51 GMT]]></title><description><![CDATA[<p dir="auto">It will not work - either use CSS or a custom Style. Afaics the stylesheet stuff is internal so you can't access it.</p>
]]></description><link>https://forum.qt.io/post/551445</link><guid isPermaLink="true">https://forum.qt.io/post/551445</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Tue, 17 Sep 2019 04:57:51 GMT</pubDate></item></channel></rss>