Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
exampleqjsascontainer.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
6
7 class Cache : public QObject
8 {
11
12 public:
14 if (auto it = m_cache.constFind(key); it != m_cache.constEnd()) {
15 return *it; // impicit conversion
16 } else {
17 return QJSValue::UndefinedValue; // implicit conversion
18 }
19 }
20
21 QHash<QString, QString> m_cache;
22 }
23
[qjs-as-container]
QHash< QString, QString > m_cache
Q_INVOKABLE QJSValue lookup(const QString &key)
const_iterator constFind(const Key &key) const noexcept
Definition qhash.h:1299
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
Definition qhash.h:1219
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
@ UndefinedValue
Definition qjsvalue.h:35
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QSet< QString >::iterator it
GLuint64 key
#define QML_ELEMENT
#define Q_OBJECT
#define Q_INVOKABLE