summaryrefslogtreecommitdiff
path: root/src/layouts
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2014-01-23 18:21:14 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-27 11:01:32 +0100
commit9267bd4e2f52e22f73b37e6a8d974b8eaa51f85d (patch)
tree5ff3a5873b6618f13791a9767b03016f97584bc9 /src/layouts
parent333381350ba3792f41cb117854ec8bfdccb225ca (diff)
downloadqtquickcontrols-9267bd4e2f52e22f73b37e6a8d974b8eaa51f85d.tar.gz
Make sure that items don't exceed the layout-computed boundary
When geometries were rounded to their nearest pixel grid geometry they sometimes exceeded the area the layout calculated them to cover. This could often be observed by that the visual spacing got shrunk to a smaller size than was specified. For small spacings values the visual spacing could even disappear. With this fix the visual spacing should never be smaller than the specified spacings value (but might be bigger due to rounding). Task-number: QTBUG-36235 Change-Id: I5142c793460e50fd2de397abfd2ea6730f1bd042 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'src/layouts')
-rw-r--r--src/layouts/qquickgridlayoutengine_p.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/layouts/qquickgridlayoutengine_p.h b/src/layouts/qquickgridlayoutengine_p.h
index 886dd850..94b8677a 100644
--- a/src/layouts/qquickgridlayoutengine_p.h
+++ b/src/layouts/qquickgridlayoutengine_p.h
@@ -55,6 +55,7 @@
#include <QtGui/private/qgridlayoutengine_p.h>
#include <QtGui/private/qlayoutpolicy_p.h>
+#include <QtCore/qmath.h>
#include "qquickitem.h"
#include "qquicklayout_p.h"
@@ -112,9 +113,10 @@ public:
void setGeometry(const QRectF &rect)
{
- const QRect r(rect.toRect());
- const QSize newSize(r.size());
- m_item->setPosition(r.topLeft());
+ const QPoint innerTopLeft(qCeil(rect.left()), qCeil(rect.top()));
+ const QPoint innerBottomRight(qFloor(rect.right()), qFloor(rect.bottom()));
+ const QSize newSize(innerBottomRight.x() - innerTopLeft.x(), innerBottomRight.y() - innerTopLeft.y());
+ m_item->setPosition(innerTopLeft);
QSizeF oldSize(m_item->width(), m_item->height());
if (newSize == oldSize) {
if (QQuickLayout *lay = qobject_cast<QQuickLayout *>(m_item))