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
qqmlpropertybindingbase_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 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
4
5
#
ifndef
QQMLPROPERTYBINDINGBASE_P_H
6
#
define
QQMLPROPERTYBINDINGBASE_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
private
/
qproperty_p
.
h
>
20
#
include
<
private
/
qqmlpropertyindex_p
.
h
>
21
22
#
include
<
QtQml
/
qtqmlglobal
.
h
>
23
24
QT_BEGIN_NAMESPACE
25
26
class
QQmlPropertyBindingBase :
public
QPropertyBindingPrivate
27
{
28
public
:
29
enum
class
HasBoundFunction :
bool
{
30
No =
false
,
31
Yes =
true
,
32
};
33
34
enum
class
IsUndefined :
bool
{
35
No =
false
,
36
Yes =
true
,
37
};
38
39
enum
class
BindingKind : quint8 {
40
JavaScript = 0,
41
PropertyToProperty = 1,
42
};
43
44
BindingKind bindingKind()
const
{
return
targetData()->bindingKind; }
45
46
bool
isUndefined()
const
{
return
bool
(targetData()->isUndefined); }
47
48
protected
:
49
QQmlPropertyBindingBase(QObject *target, QQmlPropertyIndex targetIndex,
50
QMetaType targetMetaType,
51
const
QtPrivate::BindingFunctionVTable *vtable, BindingKind bindingKind,
52
HasBoundFunction hasBoundFunction = HasBoundFunction::No)
53
: QPropertyBindingPrivate(targetMetaType, vtable, {},
true
)
54
{
55
static_assert
(std::is_trivially_destructible_v<TargetData>);
56
static_assert
(
sizeof
(TargetData) +
sizeof
(DeclarativeErrorCallback)
57
<=
sizeof
(QPropertyBindingSourceLocation));
58
static_assert
(
alignof
(TargetData) <=
alignof
(QPropertyBindingSourceLocation));
59
new
(&declarativeExtraData)
60
TargetData{ target, targetIndex, hasBoundFunction, IsUndefined::No, bindingKind };
61
}
62
63
QObject *target()
const
{
return
targetData()->target; }
64
65
QQmlPropertyIndex targetIndex()
const
{
return
targetData()->targetIndex; }
66
67
bool
hasBoundFunction()
const
68
{
69
return
targetData()->hasBoundFunction == HasBoundFunction::Yes;
70
}
71
72
void
setIsUndefined(
bool
isUndefined)
73
{
74
targetData()->isUndefined = isUndefined ? IsUndefined::Yes : IsUndefined::No;
75
}
76
77
private
:
78
struct
TargetData
79
{
80
QObject *target =
nullptr
;
81
QQmlPropertyIndex targetIndex;
82
HasBoundFunction hasBoundFunction = HasBoundFunction::No;
83
IsUndefined isUndefined = IsUndefined::No;
84
BindingKind bindingKind = BindingKind::JavaScript;
85
};
86
87
static
constexpr
size_t kindOffset() {
return
sizeof
(declarativeExtraData) - 2; }
88
89
TargetData *targetData()
90
{
91
return
std::launder(
reinterpret_cast
<TargetData *>(&declarativeExtraData));
92
}
93
94
const
TargetData *targetData()
const
95
{
96
return
std::launder(
reinterpret_cast
<
const
TargetData *>(&declarativeExtraData));
97
}
98
};
99
100
QT_END_NAMESPACE
101
102
#
endif
// QQMLPROPERTYBINDINGBASE_P_H
qtdeclarative
src
qml
qml
qqmlpropertybindingbase_p.h
Generated on
for Qt by
1.18.0