diff options
Diffstat (limited to 'src/quickcontrolsimpl/qquickplaceholdertext.cpp')
-rw-r--r-- | src/quickcontrolsimpl/qquickplaceholdertext.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/quickcontrolsimpl/qquickplaceholdertext.cpp b/src/quickcontrolsimpl/qquickplaceholdertext.cpp index 5f47a4087d..4a1fb0db00 100644 --- a/src/quickcontrolsimpl/qquickplaceholdertext.cpp +++ b/src/quickcontrolsimpl/qquickplaceholdertext.cpp @@ -16,10 +16,25 @@ QQuickPlaceholderText::QQuickPlaceholderText(QQuickItem *parent) : QQuickText(pa void QQuickPlaceholderText::componentComplete() { QQuickText::componentComplete(); - connect(parentItem(), SIGNAL(effectiveHorizontalAlignmentChanged()), this, SLOT(updateAlignment())); + + auto control = textControl(); + if (control) + connect(control, SIGNAL(effectiveHorizontalAlignmentChanged()), this, SLOT(updateAlignment())); updateAlignment(); } +/*! + \internal + + The control that we're representing. This exists because + parentItem() is not always the control - it may be a Flickable + in the case of TextArea. +*/ +QQuickItem *QQuickPlaceholderText::textControl() const +{ + return qobject_cast<QQuickItem *>(parent()); +} + void QQuickPlaceholderText::updateAlignment() { if (QQuickTextInput *input = qobject_cast<QQuickTextInput *>(parentItem())) { |