Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickplaceholdertext.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtQuick/private/qquicktext_p_p.h>
7#include <QtQuick/private/qquicktextinput_p_p.h>
8#include <QtQuick/private/qquicktextedit_p_p.h>
9
11
12QQuickPlaceholderText::QQuickPlaceholderText(QQuickItem *parent) : QQuickText(parent)
13{
14}
15
16void QQuickPlaceholderText::componentComplete()
17{
18 QQuickText::componentComplete();
19
20 auto control = textControl();
21 if (control)
22 connect(control, SIGNAL(effectiveHorizontalAlignmentChanged()), this, SLOT(updateAlignment()));
23 updateAlignment();
24}
25
26/*!
27 \internal
28
29 The control that we're representing. This exists because
30 parentItem() is not always the control - it may be a Flickable
31 in the case of TextArea.
32*/
33QQuickItem *QQuickPlaceholderText::textControl() const
34{
35 return qobject_cast<QQuickItem *>(parent());
36}
37
38void QQuickPlaceholderText::updateAlignment()
39{
40 if (QQuickTextInput *input = qobject_cast<QQuickTextInput *>(parentItem())) {
41 if (QQuickTextInputPrivate::get(input)->hAlignImplicit)
42 resetHAlign();
43 else
44 setHAlign(static_cast<HAlignment>(input->hAlign()));
45 } else if (QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(parentItem())) {
46 if (QQuickTextEditPrivate::get(edit)->hAlignImplicit)
47 resetHAlign();
48 else
49 setHAlign(static_cast<HAlignment>(edit->hAlign()));
50 } else {
51 resetHAlign();
52 }
53}
54
55QT_END_NAMESPACE
56
57#include "moc_qquickplaceholdertext_p.cpp"
Combined button and popup list for selecting options.