diff options
Diffstat (limited to 'src/quicktemplates2/qquicklabel.cpp')
-rw-r--r-- | src/quicktemplates2/qquicklabel.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index c8b125ca..44baf1c3 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -95,6 +95,22 @@ QQuickLabelPrivate::~QQuickLabelPrivate() #endif } +void QQuickLabelPrivate::resizeBackground() +{ + Q_Q(QQuickLabel); + if (background) { + QQuickItemPrivate *p = QQuickItemPrivate::get(background); + if (!p->widthValid) { + background->setWidth(q->width()); + p->widthValid = false; + } + if (!p->heightValid) { + background->setHeight(q->height()); + p->heightValid = false; + } + } +} + /*! \internal @@ -232,6 +248,8 @@ void QQuickLabel::setBackground(QQuickItem *background) background->setParentItem(this); if (qFuzzyIsNull(background->z())) background->setZ(-1); + if (isComponentComplete()) + d->resizeBackground(); } if (!d->background.isExecuting()) emit backgroundChanged(); @@ -267,17 +285,7 @@ void QQuickLabel::geometryChanged(const QRectF &newGeometry, const QRectF &oldGe { Q_D(QQuickLabel); QQuickText::geometryChanged(newGeometry, oldGeometry); - if (d->background) { - QQuickItemPrivate *p = QQuickItemPrivate::get(d->background); - if (!p->widthValid) { - d->background->setWidth(newGeometry.width()); - p->widthValid = false; - } - if (!p->heightValid) { - d->background->setHeight(newGeometry.height()); - p->heightValid = false; - } - } + d->resizeBackground(); } QT_END_NAMESPACE |