From 1b3b76b0ebc7620a9af3e73c7a7ed88276efbcfb Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Mon, 7 Apr 2025 17:21:41 +0200 Subject: [PATCH] [PATCH] layout: Set implicit width of ToolBarLayout before using its width Split setting implicit size into setting width and height separately, so that we if we use width() it will use the implicit width if no width was set yet. This avoids us hiding all actions because width is 0, only to then show them again because implicit width (and thus width) is now a valid value. Gbp-Pq: Name upstream_81352c22_layout-Set-implicit-width-of-ToolBarLayout-before-using-its-width.patch --- src/layouts/toolbarlayout.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/layouts/toolbarlayout.cpp b/src/layouts/toolbarlayout.cpp index dce591b..2e214c2 100644 --- a/src/layouts/toolbarlayout.cpp +++ b/src/layouts/toolbarlayout.cpp @@ -441,6 +441,8 @@ void ToolBarLayoutPrivate::calculateImplicitSize() visibleActionsWidth = 0.0; + q->setImplicitWidth(maxWidth); + if (maxWidth > q->width() - (hiddenActions.isEmpty() ? 0.0 : moreButtonInstance->width() + spacing)) { // We have more items than fit into the view, so start hiding some. @@ -473,7 +475,8 @@ void ToolBarLayoutPrivate::calculateImplicitSize() maxHeight = std::max(maxHeight, moreButtonInstance->implicitHeight()); }; - q->setImplicitSize(maxWidth, maxHeight); + q->setImplicitHeight(maxHeight); + Q_EMIT q->hiddenActionsChanged(); implicitSizeValid = true; -- 2.30.2