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
doc_src_qcache.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QCache>
5
6struct Employee {
7 void setId(int id);
8 int id() const { return 0; }
9 void setName(const QString &name);
10};
11
12struct MyDataStructure { };
13
14void example()
15{
16 //! [0]
17 QCache<int, Employee> cache;
18 //! [0]
19
20
21 //! [1]
22 Employee *employee = new Employee;
23 employee->setId(37);
24 employee->setName("Richard Schmit");
25 //...
26 cache.insert(employee->id(), employee);
27 //! [1]
28
29 {
30 //! [2]
31 QCache<int, MyDataStructure> cache(5000);
32 //! [2]
33 }
34}
int id() const
void setName(const QString &name)
void setId(int id)
void example()
[5]