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
qqmlmetaobject.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 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
6
7#include <private/qqmlengine_p.h>
8#include <private/qqmlpropertycachemethodarguments_p.h>
9
11
12void QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(QMetaObject::Call type, const QMetaObject **metaObject, int *index)
13{
14 int offset;
15
16 switch (type) {
17 case QMetaObject::ReadProperty:
18 case QMetaObject::WriteProperty:
19 case QMetaObject::ResetProperty:
20 offset = (*metaObject)->propertyOffset();
21 while (*index < offset) {
22 *metaObject = (*metaObject)->superClass();
23 offset = (*metaObject)->propertyOffset();
24 }
25 break;
26 case QMetaObject::InvokeMetaMethod:
27 offset = (*metaObject)->methodOffset();
28 while (*index < offset) {
29 *metaObject = (*metaObject)->superClass();
30 offset = (*metaObject)->methodOffset();
31 }
32 break;
33 default:
34 offset = 0;
35 Q_UNIMPLEMENTED();
36 offset = INT_MAX;
37 }
38
39 *index -= offset;
40}
41
42QMetaType QQmlMetaObject::methodReturnType(
43 const QQmlPropertyData &data, QString *unknownTypeError) const
44{
45 Q_ASSERT(_m && data.coreIndex() >= 0);
46
47 QMetaType type = data.propType();
48 if (!type.isValid()) {
49 // Find the return type name from the method info
50 type = _m->method(data.coreIndex()).returnMetaType();
51 }
52
53 if (type.flags().testFlag(QMetaType::IsEnumeration))
54 type = type.underlyingType();
55
56 if (type.isValid())
57 return type;
58
59 if (unknownTypeError) {
60 *unknownTypeError = QLatin1String("Unknown method return type: ")
61 + QString::fromUtf8(_m->method(data.coreIndex()).typeName());
62 }
63
64 return QMetaType();
65}
66
67QT_END_NAMESPACE
Combined button and popup list for selecting options.