aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qtsupport/exampleslistmodel.cpp
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2023-08-02 12:41:28 +0200
committerAlessandro Portale <alessandro.portale@qt.io>2023-08-02 14:35:51 +0000
commitd060d1b2244e9de75d9e5960df16b9c9e13ce449 (patch)
tree85c32e938a7c185100c5191ccb02f04fb8b07cc4 /src/plugins/qtsupport/exampleslistmodel.cpp
parent197d80f99b987e70ce102f47f0e9a1c393601320 (diff)
QtSupport: Use QImage::fromData instead of QImageReader
QImage offers this convenience shortcut since Qt 6.2. Change-Id: Ia1b286597ed13bcadeb663cf80b3dd3da964c5b7 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/qtsupport/exampleslistmodel.cpp')
-rw-r--r--src/plugins/qtsupport/exampleslistmodel.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp
index 6835ec6000..3254df00a9 100644
--- a/src/plugins/qtsupport/exampleslistmodel.cpp
+++ b/src/plugins/qtsupport/exampleslistmodel.cpp
@@ -9,7 +9,6 @@
#include <QApplication>
#include <QDir>
#include <QFile>
-#include <QImageReader>
#include <QPixmapCache>
#include <QUrl>
@@ -244,13 +243,10 @@ static QPixmap fetchPixmapAndUpdatePixmapCache(const QString &url)
return pixmap;
if (url.startsWith("qthelp://")) {
- QByteArray fetchedData = Core::HelpManager::fileData(url);
+ const QByteArray fetchedData = Core::HelpManager::fileData(url);
if (!fetchedData.isEmpty()) {
- QBuffer imgBuffer(&fetchedData);
- imgBuffer.open(QIODevice::ReadOnly);
- QImageReader reader(&imgBuffer, QFileInfo(url).suffix().toLatin1());
- QImage img = reader.read();
- img.convertTo(QImage::Format_RGB32);
+ const QImage img = QImage::fromData(fetchedData, QFileInfo(url).suffix().toLatin1())
+ .convertToFormat(QImage::Format_RGB32);
const int dpr = qApp->devicePixelRatio();
// boundedTo -> don't scale thumbnails up
const QSize scaledSize =