diff options
author | Alexandr Akulich <akulichalexander@gmail.com> | 2016-06-16 10:40:12 +0500 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-10-20 12:33:19 +0000 |
commit | 5a979e2d24b51e931a158062d322d0340e666bff (patch) | |
tree | f61123b92ec5499c759076620db327c3960f7607 /src/quick/items/qquickloader.cpp | |
parent | e3e890dbb3106c8360d6c4a75b7905b7b1a75f09 (diff) |
QQuickLoader: Use setSize() to resize item
Sequential call of setWidth() and setHeight() results in outdated height on
widthChanged() signal. Use setSize() to set width and height at once.
Change-Id: I86ff5cef2da912a8855c66a614d5d7d2e71f1de8
Reviewed-by: Risto Avila <risto.avila@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickloader.cpp')
-rw-r--r-- | src/quick/items/qquickloader.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp index cd356a9eeb..27afe5a5db 100644 --- a/src/quick/items/qquickloader.cpp +++ b/src/quick/items/qquickloader.cpp @@ -916,9 +916,14 @@ void QQuickLoaderPrivate::_q_updateSize(bool loaderGeometryChanged) if (!item) return; - if (loaderGeometryChanged && q->widthValid()) + const bool needToUpdateWidth = loaderGeometryChanged && q->widthValid(); + const bool needToUpdateHeight = loaderGeometryChanged && q->heightValid(); + + if (needToUpdateWidth && needToUpdateHeight) + item->setSize(QSizeF(q->width(), q->height())); + else if (needToUpdateWidth) item->setWidth(q->width()); - if (loaderGeometryChanged && q->heightValid()) + else if (needToUpdateHeight) item->setHeight(q->height()); if (updatingSize) |