summaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2017-02-06 09:37:13 +0100
committerAlbert Astals Cid <albert.astals@canonical.com>2017-02-08 10:07:41 +0000
commitade0ed7fa9ad06a1dc1312e7abad8baf20f7b756 (patch)
treec0d32c4ba0191e17eb6729c9104cc644b799f0a0 /examples/quick
parent6cfeabe92db25a10812a657f7f4fdadfb505204d (diff)
Improve QQuickAsyncImageProvider example
Also link it from more places Change-Id: Ib5fbf89f4a039f885e918d57ee477e9788049d8d Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/imageresponseprovider/imageresponseprovider.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/quick/imageresponseprovider/imageresponseprovider.cpp b/examples/quick/imageresponseprovider/imageresponseprovider.cpp
index a888c823a6..d4633b779a 100644
--- a/examples/quick/imageresponseprovider/imageresponseprovider.cpp
+++ b/examples/quick/imageresponseprovider/imageresponseprovider.cpp
@@ -51,37 +51,37 @@ class AsyncImageResponse : public QQuickImageResponse, public QRunnable
{
public:
AsyncImageResponse(const QString &id, const QSize &requestedSize)
- : m_id(id), m_requestedSize(requestedSize), m_texture(0)
+ : m_id(id), m_requestedSize(requestedSize)
{
setAutoDelete(false);
}
QQuickTextureFactory *textureFactory() const
{
- return m_texture;
+ return QQuickTextureFactory::textureFactoryForImage(m_image);
}
void run()
{
- QImage image(50, 50, QImage::Format_RGB32);
+ m_image = QImage(50, 50, QImage::Format_RGB32);
if (m_id == "slow") {
qDebug() << "Slow, red, sleeping for 5 seconds";
QThread::sleep(5);
- image.fill(Qt::red);
+ m_image.fill(Qt::red);
} else {
qDebug() << "Fast, blue, sleeping for 1 second";
QThread::sleep(1);
- image.fill(Qt::blue);
+ m_image.fill(Qt::blue);
}
if (m_requestedSize.isValid())
- image = image.scaled(m_requestedSize);
- m_texture = QQuickTextureFactory::textureFactoryForImage(image);
+ m_image = m_image.scaled(m_requestedSize);
+
emit finished();
}
QString m_id;
QSize m_requestedSize;
- QQuickTextureFactory *m_texture;
+ QImage m_image;
};
class AsyncImageProvider : public QQuickAsyncImageProvider