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
qqmlpropertymap.h
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
4
5#ifndef QQMLPROPERTYMAP_H
6#define QQMLPROPERTYMAP_H
7
8#include <QtQml/qtqmlglobal.h>
9#include <QtQml/qqmlregistration.h>
10#include <QtQml/qqmlprivate.h>
11
12#include <QtCore/QObject>
13#include <QtCore/QHash>
14#include <QtCore/QStringList>
15#include <QtCore/QVariant>
16
17QT_BEGIN_NAMESPACE
18
19
20class QQmlPropertyMapPrivate;
21class Q_QML_EXPORT QQmlPropertyMap : public QObject
22{
23 Q_OBJECT
24 QML_ANONYMOUS
25public:
26#if QT_DEPRECATED_SINCE(6, 11)
27 QT_DEPRECATED_VERSION_X_6_11("Use create() or the protected two-argument constructor instead.")
28 explicit QQmlPropertyMap(QObject *parent = nullptr);
29#endif
30
31 static QQmlPropertyMap *create(QObject *parent = nullptr);
32
33 ~QQmlPropertyMap() override;
34
35 QVariant value(const QString &key) const;
36 void insert(const QString &key, const QVariant &value);
37 void insert(const QVariantHash &values);
38 void clear(const QString &key);
39 void freeze();
40
41 Q_INVOKABLE QStringList keys() const;
42
43 int count() const;
44 int size() const;
45 bool isEmpty() const;
46 bool contains(const QString &key) const;
47
48 QVariant &operator[](const QString &key);
49 QVariant operator[](const QString &key) const;
50
51Q_SIGNALS:
52 void valueChanged(const QString &key, const QVariant &value);
53
54protected:
55 virtual QVariant updateValue(const QString &key, const QVariant &input);
56
57 template<class DerivedType>
58 QQmlPropertyMap(DerivedType *derived, QObject *parentObj)
59 : QQmlPropertyMap(&DerivedType::staticMetaObject, parentObj)
60 {
61 Q_UNUSED(derived);
62 }
63
64private:
65 friend class QtPrivate::QMetaTypeForType<QQmlPropertyMap>;
66
67 QQmlPropertyMap(const QMetaObject *staticMetaObject, QObject *parent);
68
69 Q_DECLARE_PRIVATE(QQmlPropertyMap)
70 Q_DISABLE_COPY(QQmlPropertyMap)
71};
72
73namespace QtPrivate {
74template<>
81}
82
83namespace QQmlPrivate {
84
85// Specialization of QQmlElement for QQmlPropertyMap, for the rare case
86// when you'd want to register QQmlPropertyMap directly, rather than some
87// derived class of it.
88template<>
90
91}
92
93QT_END_NAMESPACE
94
95#endif
const QString & propertyName(int index)
void propertyWritten(int index) override
QVariant propertyWriteValue(int, const QVariant &) override
void propertyCreated(int, QMetaPropertyBuilder &) override
QQmlPropertyMapMetaObject(QQmlPropertyMap *obj, QQmlPropertyMapPrivate *objPriv, const QMetaObject *staticMetaObject)
QVariant updateValue(const QString &key, const QVariant &input)
void emitChanged(const QString &key, const QVariant &value)
const QString & propertyName(int index) const
static bool validKeyName(const QString &name)
The QQmlPropertyMap class allows you to set key-value pairs that can be used in QML bindings.
Combined button and popup list for selecting options.