Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquicktextutil.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 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
// Qt-Security score:significant reason:default
4
5
#
include
"qquicktextutil_p.h"
6
7
#
include
<
QtQml
/
qqmlinfo
.
h
>
8
#
include
<
QtQml
/
qqmlcomponent
.
h
>
9
10
#
include
<
private
/
qqmlglobal_p
.
h
>
11
#
include
<
private
/
qquickitem_p
.
h
>
12
13
QT_BEGIN_NAMESPACE
14
15
QQuickItem *QQuickTextUtil::createCursor(
16
QQmlComponent *component, QQuickItem *parent,
const
QRectF &rectangle,
const
char
*className)
17
{
18
QQuickItem *item =
nullptr
;
19
if
(component->isReady()) {
20
QQmlContext *creationContext = component->creationContext();
21
22
if
(QObject *object = component->beginCreate(creationContext
23
? creationContext
24
: qmlContext(parent))) {
25
if
((item = qobject_cast<QQuickItem *>(object))) {
26
QQml_setParent_noEvent(item, parent);
27
item->setParentItem(parent);
28
item->setPosition(rectangle.topLeft());
29
item->setHeight(rectangle.height());
30
}
else
{
31
qmlWarning(parent) << tr(
"%1 does not support loading non-visual cursor delegates."
)
32
.arg(QString::fromUtf8(className));
33
}
34
component->completeCreate();
35
if
(parent->clip())
36
QQuickItemPrivate::get(parent)->dirty(QQuickItemPrivate::Size);
37
return
item;
38
}
39
}
else
if
(component->isLoading()) {
40
QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)),
41
parent, SLOT(createCursor()), Qt::UniqueConnection);
42
return
item;
43
}
44
qmlWarning(parent, component->errors()) << tr(
"Could not load cursor delegate"
);
45
return
item;
46
}
47
48
qreal QQuickTextUtil::alignedX(
const
qreal textWidth,
const
qreal itemWidth,
int
alignment)
49
{
50
qreal x = 0;
51
switch
(alignment) {
52
case
Qt::AlignLeft:
53
case
Qt::AlignJustify:
54
break
;
55
case
Qt::AlignRight:
56
x = itemWidth - textWidth;
57
break
;
58
case
Qt::AlignHCenter:
59
x = (itemWidth - textWidth) / 2;
60
break
;
61
}
62
return
x;
63
}
64
65
qreal QQuickTextUtil::alignedY(
const
qreal textHeight,
const
qreal itemHeight,
int
alignment)
66
{
67
qreal y = 0;
68
switch
(alignment) {
69
case
Qt::AlignTop:
70
break
;
71
case
Qt::AlignBottom:
72
y = itemHeight - textHeight;
73
break
;
74
case
Qt::AlignVCenter:
75
y = (itemHeight - textHeight) / 2;
76
break
;
77
}
78
return
y;
79
}
80
81
QT_END_NAMESPACE
82
83
#
include
"moc_qquicktextutil_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
quick
items
qquicktextutil.cpp
Generated on
for Qt by
1.18.0