<?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[ActiveFocus draws outside rounded menu corners]]></title><description><![CDATA[<p dir="auto">Hi!<br />
I'm trying to make a menu with rounded corners using components from QtQuick.Controls 2.15.<br />
However, the activeFocus background from the MenuItems is not rounded, and so the corners of the MenuItem background ends up sticking out from the menu background for the top and bottom choice when hovered over.</p>
<p dir="auto">Is it possible to ensure that the MenuItem background does not protrude from the Menu background?</p>
<p dir="auto">Thanks for any responses, and please ask for more information if needed. I'm new to qt :)</p>
]]></description><link>https://forum.qt.io/topic/119914/activefocus-draws-outside-rounded-menu-corners</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 08:17:30 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/119914.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 13 Oct 2020 15:13:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ActiveFocus draws outside rounded menu corners on Thu, 15 Oct 2020 14:17:36 GMT]]></title><description><![CDATA[<p dir="auto">I'll keep that in mind next time, thanks.</p>
<p dir="auto">It turns out what I wanted had a name, clipping. You can set <code>clip: true</code>, and that should prevent the menuitems' backgrounds from drawing outside of the menu itself. However, due to performance concerns, clip regions can only be rectangular so that did not solve the problem in this case.</p>
<p dir="auto">The solution was to redefine the background of the menuItems like this:<br />
(keep in mind that I'm still a noob, so while this code solves this specific problem, it might not be so great in other ways)</p>
<pre><code>background: Item {
        height: root.implicitHeight 
        width: root.implicitWidth
        anchors.bottom: root.bottom
        opacity: root.activeFocus ? 0.5 : 0
        layer.enabled: true
        Rectangle {
            implicitHeight: 0.5 * root.implicitHeight
            color: "#000000"
            opacity: (root.activeFocus &amp;&amp; (isFirst || isLast)) ? 1 : 0
            anchors.top: isFirst ? undefined : roundRect.top
            anchors.right: roundRect.right
            anchors.left: roundRect.left
            anchors.bottom: isFirst ? roundRect.bottom : undefined
            visible: opacity
        }
        Rectangle {
            id: roundRect
            radius: (isLast || isFirst) ? 15 : 0
            implicitHeight: root.implicitHeight
            color: "#000000"
            anchors.fill: parent
        }
    }
</code></pre>
]]></description><link>https://forum.qt.io/post/622418</link><guid isPermaLink="true">https://forum.qt.io/post/622418</guid><dc:creator><![CDATA[qthackerman]]></dc:creator><pubDate>Thu, 15 Oct 2020 14:17:36 GMT</pubDate></item><item><title><![CDATA[Reply to ActiveFocus draws outside rounded menu corners on Wed, 14 Oct 2020 19:07:57 GMT]]></title><description><![CDATA[<p dir="auto">Post your working code, it's the quickest way to get a response.</p>
]]></description><link>https://forum.qt.io/post/622265</link><guid isPermaLink="true">https://forum.qt.io/post/622265</guid><dc:creator><![CDATA[Markkyboy]]></dc:creator><pubDate>Wed, 14 Oct 2020 19:07:57 GMT</pubDate></item></channel></rss>