From c02f286f012b048bae0330d16ca3f3344d7461b2 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Fri, 29 Jul 2022 03:02:54 +0300 Subject: [PATCH] fix boxlayout adding extra spacing --- src/BoxLayout.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BoxLayout.cpp b/src/BoxLayout.cpp index 0d9cd20..0c0412c 100644 --- a/src/BoxLayout.cpp +++ b/src/BoxLayout.cpp @@ -57,7 +57,13 @@ void BoxLayout::run() { } } - double space_per_unslotted_widget = free_space / unslotted_widgets - m_spacing; + double spacing_targets = (unslotted_widgets - 1); + if (spacing_targets < 0) + spacing_targets = 0; + + free_space -= spacing_targets * m_spacing; + + double space_per_unslotted_widget = free_space / unslotted_widgets; for (unsigned int i = 0; i < m_target->children().size(); i++) { auto child = m_target->children()[i];