aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets
diff options
context:
space:
mode:
authorAlexandr Akulich <akulichalexander@gmail.com>2016-06-02 23:59:04 +0500
committerShawn Rutledge <shawn.rutledge@qt.io>2016-07-12 11:15:57 +0000
commit2418a36d0a83c22a12654caa5138a0bc4f84e9f3 (patch)
tree230b1e729aad4e54c678a3e60093e826f2f53434 /src/quickwidgets
parent5f4eb78ccb0639ec77b45ae1a94c137a77e74d8c (diff)
Set width and height simultaneously on SizeRootObjectToView
On QQuickView/QQuickWidget size update we used set width (with the notify signal emission) and then height (with signal emission again). This way code, relying on width and height would be triggered twice and at the first time with there would be outdated height value. The new code takes care on proper value for both width and height. Change-Id: I6525911c40af0ca6a26ab3e7dac16d32a96d9a27 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quickwidgets')
-rw-r--r--src/quickwidgets/qquickwidget.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 4f22cad472..2a014546e1 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -758,9 +758,14 @@ void QQuickWidgetPrivate::updateSize()
q->resize(newSize);
}
} else if (resizeMode == QQuickWidget::SizeRootObjectToView) {
- if (!qFuzzyCompare(q->width(), root->width()))
+ bool needToUpdateWidth = !qFuzzyCompare(q->width(), root->width());
+ bool needToUpdateHeight = !qFuzzyCompare(q->height(), root->height());
+
+ if (needToUpdateWidth && needToUpdateHeight)
+ root->setSize(QSizeF(q->width(), q->height()));
+ else if (needToUpdateWidth)
root->setWidth(q->width());
- if (!qFuzzyCompare(q->height(), root->height()))
+ else if (needToUpdateHeight)
root->setHeight(q->height());
}
}