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
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
5
//! [qjs-as-container]
6
7
class
Cache
:
public
QObject
8
{
9
Q_OBJECT
10
QML_ELEMENT
11
12
public
:
13
Q_INVOKABLE
QJSValue
lookup
(
const
QString
&
key
) {
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
24
//! [qjs-as-container]
Cache
[qjs-as-container]
Definition
exampleqjsascontainer.cpp:8
qtdeclarative
src
qml
doc
snippets
qtjavascript
integratingjswithcpp
exampleqjsascontainer.cpp
Generated on
for Qt by
1.14.0