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> on behalf of Alexander Dyagilev <alervd...@gmail.com> Date: Thursday, 3 October 2024 at 2:47 PM To: Qt Project <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