<?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 properly draw QComboBox&#x27;s view?]]></title><description><![CDATA[<p dir="auto">I subclassed QComboBox and have overridden the paintEvent() of it, but when I filter the paintEvent of the view it's still drawing the default style.</p>
<pre><code>  if(event-&gt;type() == QEvent::Paint &amp;&amp; object == view()) {
    auto e = static_cast&lt;QPaintEvent*&gt;(event);
    auto painter = QPainter(view());
    painter.fillRect(e-&gt;rect(), Qt::black);
    painter.fillRect(1, 1, view()-&gt;width() - 2, view()-&gt;height() - 2,
      Qt::white);
    return true;
  }
</code></pre>
<p dir="auto">With this code I expected to see a white view with a black border and no items in the list. But, I get the default view drawn with a black border on the bottom and right edges.</p>
<p dir="auto">How to I prevent the view from being drawn? Shouldn't returning true from the filter prevent the default view style from being drawn?</p>
]]></description><link>https://forum.qt.io/topic/96544/how-to-properly-draw-qcombobox-s-view</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 20:27:18 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/96544.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 Nov 2018 21:23:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to properly draw QComboBox&#x27;s view? on Mon, 12 Nov 2018 21:51:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a></p>
<p dir="auto">Thanks, I'll take a look.</p>
]]></description><link>https://forum.qt.io/post/492734</link><guid isPermaLink="true">https://forum.qt.io/post/492734</guid><dc:creator><![CDATA[Qt_User72653]]></dc:creator><pubDate>Mon, 12 Nov 2018 21:51:48 GMT</pubDate></item><item><title><![CDATA[Reply to How to properly draw QComboBox&#x27;s view? on Mon, 12 Nov 2018 21:50:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qt_user72653">@<bdi>Qt_User72653</bdi></a><br />
Ah, its plenty.<br />
Well yes, a custom view should be more optimal then.<br />
You can use<br />
<a href="https://code.woboq.org/qt5/qtbase/src/widgets/itemviews/qlistview.cpp.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://code.woboq.org/qt5/qtbase/src/widgets/itemviews/qlistview.cpp.html</a><br />
to have a look of handling states etc.</p>
]]></description><link>https://forum.qt.io/post/492733</link><guid isPermaLink="true">https://forum.qt.io/post/492733</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Mon, 12 Nov 2018 21:50:40 GMT</pubDate></item><item><title><![CDATA[Reply to How to properly draw QComboBox&#x27;s view? on Mon, 12 Nov 2018 21:45:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a></p>
<ul>
<li>New background color for hovered item</li>
<li>Padding for hovered item</li>
<li>Custom border color for top, with a different color for bottom and sides</li>
<li>Remove the outline for the hovered item</li>
<li>Custom size for list items</li>
</ul>
<p dir="auto">That's just off the top of my head, there's a few more things I'm forgetting. Some of this works with CSS, some works with quirks, and some I can't get to work at all, so, I figured I would just draw it myself rather than try to deal with the issues with CSS.</p>
<p dir="auto">I originally considered making a custom view for it, but I didn't want to have to deal with managing items in the list; I only wanted a custom style.</p>
]]></description><link>https://forum.qt.io/post/492732</link><guid isPermaLink="true">https://forum.qt.io/post/492732</guid><dc:creator><![CDATA[Qt_User72653]]></dc:creator><pubDate>Mon, 12 Nov 2018 21:45:58 GMT</pubDate></item><item><title><![CDATA[Reply to How to properly draw QComboBox&#x27;s view? on Mon, 12 Nov 2018 21:39:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qt_user72653">@<bdi>Qt_User72653</bdi></a><br />
Hi<br />
Can i ask what is the goal of it ?<br />
other background color or completely new item drawing or ?</p>
]]></description><link>https://forum.qt.io/post/492729</link><guid isPermaLink="true">https://forum.qt.io/post/492729</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Mon, 12 Nov 2018 21:39:11 GMT</pubDate></item><item><title><![CDATA[Reply to How to properly draw QComboBox&#x27;s view? on Mon, 12 Nov 2018 21:37:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a></p>
<p dir="auto">Thanks.</p>
<p dir="auto">I was hoping to avoid having to create a new view for it, but if that's easier I'll give that a go.</p>
]]></description><link>https://forum.qt.io/post/492728</link><guid isPermaLink="true">https://forum.qt.io/post/492728</guid><dc:creator><![CDATA[Qt_User72653]]></dc:creator><pubDate>Mon, 12 Nov 2018 21:37:49 GMT</pubDate></item><item><title><![CDATA[Reply to How to properly draw QComboBox&#x27;s view? on Mon, 12 Nov 2018 21:30:43 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">If you want as custom view, it would be simpler to create your own <a href="http://doc.qt.io/qt-5/qabstractitemview.html" target="_blank" rel="noopener noreferrer nofollow ugc">QAbstractItemView</a> or <a href="http://doc.qt.io/qt-5/qlistview.html" target="_blank" rel="noopener noreferrer nofollow ugc">QListView</a> and call <a href="http://doc.qt.io/qt-5/qcombobox.html#setView" target="_blank" rel="noopener noreferrer nofollow ugc">setView</a> on your combo box.</p>
]]></description><link>https://forum.qt.io/post/492725</link><guid isPermaLink="true">https://forum.qt.io/post/492725</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 12 Nov 2018 21:30:43 GMT</pubDate></item></channel></rss>