From f842b84a5a215e7c8b9ee9c4a32d88bab4fb6f5e Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 26 Jun 2025 12:43:59 -0700 Subject: [PATCH] widgets/wrapper: round child position when centering Fixes misalignment when resizeChild is false and wrapper width is odd. --- src/widgets/marginwrapper.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/widgets/marginwrapper.cpp b/src/widgets/marginwrapper.cpp index 020e80ad..9960bba9 100644 --- a/src/widgets/marginwrapper.cpp +++ b/src/widgets/marginwrapper.cpp @@ -1,4 +1,5 @@ #include "marginwrapper.hpp" +#include #include #include @@ -39,7 +40,7 @@ MarginWrapperManager::MarginWrapperManager(QObject* parent): WrapperManager(pare auto total = this->bLeftMargin + this->bRightMargin; auto mul = total == 0 ? 0.5 : this->bLeftMargin / total; auto margin = this->bWrapperWidth - this->bChildImplicitWidth; - return margin * mul; + return std::round(margin * mul); }); this->bChildY.setBinding([this] { @@ -48,7 +49,7 @@ MarginWrapperManager::MarginWrapperManager(QObject* parent): WrapperManager(pare auto total = this->bTopMargin + this->bBottomMargin; auto mul = total == 0 ? 0.5 : this->bTopMargin / total; auto margin = this->bWrapperHeight - this->bChildImplicitHeight; - return margin * mul; + return std::round(margin * mul); }); this->bChildWidth.setBinding([this] {