diff options
author | Alexandr Akulich <akulichalexander@gmail.com> | 2016-06-02 23:59:04 +0500 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-07-12 11:15:57 +0000 |
commit | 2418a36d0a83c22a12654caa5138a0bc4f84e9f3 (patch) | |
tree | 230b1e729aad4e54c678a3e60093e826f2f53434 /src/quick/items/qquickview.cpp | |
parent | 5f4eb78ccb0639ec77b45ae1a94c137a77e74d8c (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/quick/items/qquickview.cpp')
-rw-r--r-- | src/quick/items/qquickview.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp index 0ed9167fb2..1d89c8bfc2 100644 --- a/src/quick/items/qquickview.cpp +++ b/src/quick/items/qquickview.cpp @@ -433,9 +433,14 @@ void QQuickViewPrivate::updateSize() q->resize(newSize); } } else if (resizeMode == QQuickView::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()); } } |