1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
From 81352c225ce742e373130eb2fc808e0b4a8f4eeb Mon Sep 17 00:00:00 2001
From: Arjen Hiemstra <ahiemstra@heimr.nl>
Date: Mon, 7 Apr 2025 17:21:41 +0200
Subject: [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.
---
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 dce591be3..2e214c2be 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;
--
GitLab
|