Skip to content

Commit f842b84

Browse files
committed
widgets/wrapper: round child position when centering
Fixes misalignment when resizeChild is false and wrapper width is odd.
1 parent d949f91 commit f842b84

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/widgets/marginwrapper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "marginwrapper.hpp"
2+
#include <cmath>
23

34
#include <qobject.h>
45
#include <qquickitem.h>
@@ -39,7 +40,7 @@ MarginWrapperManager::MarginWrapperManager(QObject* parent): WrapperManager(pare
3940
auto total = this->bLeftMargin + this->bRightMargin;
4041
auto mul = total == 0 ? 0.5 : this->bLeftMargin / total;
4142
auto margin = this->bWrapperWidth - this->bChildImplicitWidth;
42-
return margin * mul;
43+
return std::round(margin * mul);
4344
});
4445

4546
this->bChildY.setBinding([this] {
@@ -48,7 +49,7 @@ MarginWrapperManager::MarginWrapperManager(QObject* parent): WrapperManager(pare
4849
auto total = this->bTopMargin + this->bBottomMargin;
4950
auto mul = total == 0 ? 0.5 : this->bTopMargin / total;
5051
auto margin = this->bWrapperHeight - this->bChildImplicitHeight;
51-
return margin * mul;
52+
return std::round(margin * mul);
5253
});
5354

5455
this->bChildWidth.setBinding([this] {

0 commit comments

Comments
 (0)