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
qpixmapcache.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
4#ifndef QPIXMAPCACHE_H
5#define QPIXMAPCACHE_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtGui/qpixmap.h>
9
11
12
13class Q_GUI_EXPORT QPixmapCache
14{
15public:
16 class KeyData;
17 class Q_GUI_EXPORT Key
18 {
19 public:
20 Key();
21 Key(const Key &other);
22 Key(Key &&other) noexcept : d(other.d) { other.d = nullptr; }
23 Key &operator =(Key &&other) noexcept { swap(other); return *this; }
24 ~Key();
25 bool operator ==(const Key &key) const;
26 inline bool operator !=(const Key &key) const
27 { return !operator==(key); }
28 Key &operator =(const Key &other);
29
30 void swap(Key &other) noexcept { qt_ptr_swap(d, other.d); }
31 bool isValid() const noexcept;
32
33 private:
34 friend size_t qHash(const QPixmapCache::Key &k, size_t seed = 0) noexcept
35 { return k.hash(seed); }
36 size_t hash(size_t seed) const noexcept;
37
38 KeyData *d;
39 friend class QPMCache;
40 friend class QPixmapCache;
41 };
42
43 static int cacheLimit();
44 static void setCacheLimit(int);
45 static bool find(const QString &key, QPixmap *pixmap);
46 static bool find(const Key &key, QPixmap *pixmap);
47 static bool insert(const QString &key, const QPixmap &pixmap);
48 static Key insert(const QPixmap &pixmap);
49#if QT_DEPRECATED_SINCE(6, 6)
50 QT_DEPRECATED_VERSION_X_6_6("Use remove(key), followed by key = insert(pixmap).")
51 QT_GUI_INLINE_SINCE(6, 6)
52 static bool replace(const Key &key, const QPixmap &pixmap);
53#endif
54 static void remove(const QString &key);
55 static void remove(const Key &key);
56 static void clear();
57};
58Q_DECLARE_SHARED(QPixmapCache::Key)
59
60#if QT_DEPRECATED_SINCE(6, 6)
61#if QT_GUI_INLINE_IMPL_SINCE(6, 6)
62bool QPixmapCache::replace(const Key &key, const QPixmap &pixmap)
63{
64 if (!key.isValid())
65 return false;
66 remove(key);
67 const_cast<Key&>(key) = insert(pixmap);
68 return key.isValid();
69}
70#endif // QT_GUI_INLINE_IMPL_SINCE(6, 6)
71#endif // QT_DEPRECATED_SINCE(6, 6)
72
74
75#endif // QPIXMAPCACHE_H
The QPixmapCache::Key class can be used for efficient access to the QPixmapCache.
void swap(Key &other) noexcept
Key(Key &&other) noexcept
\inmodule QtGui
static void remove(const QString &key)
Removes the pixmap associated with key from the cache.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QHash< int, QWidget * > hash
[35multi]
b clear()
cache insert(employee->id(), employee)
Combined button and popup list for selecting options.
constexpr bool operator!=(const timespec &t1, const timespec &t2)
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
GLuint64 key
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Definition qswap.h:29
#define QT_DEPRECATED_VERSION_X_6_6(text)
settings remove("monkey")
QSharedPointer< T > other(t)
[5]
this swap(other)
widget render & pixmap