File: imageprovider.md

package info (click to toggle)
qcoro 0.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 1,700 kB
  • sloc: cpp: 8,573; python: 32; xml: 26; makefile: 23; sh: 15
file content (26 lines) | stat: -rw-r--r-- 877 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!--
SPDX-FileCopyrightText: 2022 Jonah BrĂ¼chert <jbb@kaidan.im>
SPDX-License-Identifier: GFDL-1.3-or-later
-->

# ImageProvider

{{ doctable("Quick", "QCoroImageProvider") }}

Coroutines based implementation of [`QQuickImaqeProvider`][qdoc-imageprovider].

To use `QCoro::ImageProvider`, you need to create a subclass of it, and implement the `asyncRequestImage` function, as shown in the example below:
```cpp
#include <QCoro/QCoroImageProvider>

class IconImageProvider : public QCoro::ImageProvider
{
public:
    QCoro::Task<QImage> asyncRequestImage(const QString &id, const QSize &) override;
};
```

The subclass [can be registered with a `QQmlEngine`][qdoc-addimageprovider] like any `QQuickImageProvider` subclass.

[qdoc-addimageprovider]: https://doc.qt.io/qt-5/qqmlengine.html#addImageProvider
[qdoc-imageprovider]: https://doc.qt.io/qt-5/qquickimageprovider.html