summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@qt.io>2017-09-15 08:52:23 +0300
committerMika Salmela <mika.salmela@qt.io>2017-10-06 10:56:36 +0000
commit0366f68b6d63efb2544ccd75dce5157e9c8d6313 (patch)
tree65b120352293d58b116f1919812d8d9d3bd36e02 /src/gui
parent248beda08f831d04e6b59df202921152b106bbfa (diff)
Prevent changing the width for layout item's rect
For gridlayout items the x position is rounded, but the QRectF changes the width to keep the right edge. The width is yet calculated exactly for the text so we need to preserve it. Task-number: QTBUG-61244 Change-Id: I823ba742c9ab299740232b5d9b4ad5713e1782c4 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/util/qgridlayoutengine.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp
index 8ff2a3eeec..33adac40b2 100644
--- a/src/gui/util/qgridlayoutengine.cpp
+++ b/src/gui/util/qgridlayoutengine.cpp
@@ -1051,10 +1051,12 @@ void QGridLayoutEngine::setGeometries(const QRectF &contentsGeometry, const QAbs
if (m_snapToPixelGrid) {
// x and y should already be rounded, but the call to geometryWithin() above might
// result in a geom with x,y at half-pixels (due to centering within the cell)
- geom.setX(qround(geom.x()));
+ // QRectF may change the width as it wants to maintain the right edge. In this
+ // case the width need to be preserved.
+ geom.moveLeft(qround(geom.x()));
// Do not snap baseline aligned items, since that might cause the baselines to not be aligned.
if (align != Qt::AlignBaseline)
- geom.setY(qround(geom.y()));
+ geom.moveTop(qround(geom.y()));
}
visualRect(&geom, visualDirection(), contentsGeometry);
item->setGeometry(geom);