Hey Alexander,

Nope, not a design flaw. Perfectly in keeping with QML design principles. 
Please see the following on how to customize Quick controls:
https://doc.qt.io/qt-6/qtquickcontrols-customize.html

Best,
James

From: Interest <interest-boun...@qt-project.org> on behalf of Alexander 
Dyagilev <alervd...@gmail.com>
Date: Thursday, October 3, 2024 at 11:22
To: Doris Verria <doris.ver...@qt.io>
Cc: Qt Project <interest@qt-project.org>
Subject: Re: [Interest] Change Menu background
OK, Thank you for the response. I think it's a design flaw. Background is just 
a background. It should not determine anything.

I did not change any properties of the menu control except the background. So I 
was expecting it to just become green. :)

On Thu, Oct 3, 2024 at 10:10 PM Doris Verria 
<doris.ver...@qt.io<mailto:doris.ver...@qt.io>> wrote:
Hi Alexander,

The background will automatically follow the controls size. However, the 
control uses the implicit size of the background or the content size (whichever 
is bigger) to calculate its implicit size.
So if the menu has no contentWidth/Height set and you don’t provide an implicit 
size for the background, the menu itself will have a 0x0 size. To avoid that, 
you should try either setting the contentWidth or give an implicit size to the 
background.

Note that most styles set the contentItem of the Menu to be a ListView. 
According to the documentation, a vertical ListView only estimates the 
contentHeight, and a horizontal ListView only estimates the contentWidth, while 
the other dimension is set to -1, so it is up to the application to explicitly 
set these.

Regards,
Doris Verria

From: Interest 
<interest-boun...@qt-project.org<mailto:interest-boun...@qt-project.org>> on 
behalf of Alexander Dyagilev <alervd...@gmail.com<mailto:alervd...@gmail.com>>
Date: Thursday, 3 October 2024 at 2:47 PM
To: Qt Project <interest@qt-project.org<mailto:interest@qt-project.org>>
Subject: [Interest] Change Menu background
Hello,

I'm using Qt 6.6.3.

I'm trying to customize menu.

I've created the following component:

Menu
{
    background: Rectangle {
        color: "green"
    }
}

Now my menu just does not show up. I believe it's because its size is (0,0) now.

Where am I wrong? In Qt docs it's stated, that background follows its parent's 
size.
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to