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];