summaryrefslogtreecommitdiffstats
path: root/examples/declarative/imageprovider
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-03-29 01:29:03 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-03-29 01:29:03 (GMT)
commitbe07335e426ef726a219e183d13b4a8f98bd9907 (patch)
tree606b2bcf300648ec61a45a199337733eba543781 /examples/declarative/imageprovider
parentfbd4378fa12ba8f310a3ca9f6e7c1b393f596410 (diff)
downloadQt-be07335e426ef726a219e183d13b4a8f98bd9907.zip
Qt-be07335e426ef726a219e183d13b4a8f98bd9907.tar.gz
Qt-be07335e426ef726a219e183d13b4a8f98bd9907.tar.bz2
Update for import dir and imageProvider changes.
Diffstat (limited to 'examples/declarative/imageprovider')
-rw-r--r--examples/declarative/imageprovider/imageprovider-example.qml3
-rw-r--r--examples/declarative/imageprovider/imageprovider.cpp14
2 files changed, 14 insertions, 3 deletions
diff --git a/examples/declarative/imageprovider/imageprovider-example.qml b/examples/declarative/imageprovider/imageprovider-example.qml
index a1f2794..a895821 100644
--- a/examples/declarative/imageprovider/imageprovider-example.qml
+++ b/examples/declarative/imageprovider/imageprovider-example.qml
@@ -1,5 +1,5 @@
import Qt 4.6
-import ImageProviderCore 1.0
+import "ImageProviderCore"
//![0]
ListView {
width: 100
@@ -16,6 +16,7 @@ ListView {
}
Image {
source: modelData
+ sourceSize: "50x25"
}
}
}
diff --git a/examples/declarative/imageprovider/imageprovider.cpp b/examples/declarative/imageprovider/imageprovider.cpp
index 011a63b..4c4aa94 100644
--- a/examples/declarative/imageprovider/imageprovider.cpp
+++ b/examples/declarative/imageprovider/imageprovider.cpp
@@ -61,11 +61,21 @@ class ColorImageProvider : public QDeclarativeImageProvider
{
public:
// This is run in a low priority thread.
- QImage request(const QString &id) {
- QImage image(100, 50, QImage::Format_RGB32);
+ QImage request(const QString &id, QSize *size, const QSize &req_size)
+ {
+ if (size) *size = QSize(100,50);
+ QImage image(
+ req_size.width() > 0 ? req_size.width() : 100,
+ req_size.height() > 0 ? req_size.height() : 50,
+ QImage::Format_RGB32);
image.fill(QColor(id).rgba());
QPainter p(&image);
+ QFont f = p.font();
+ f.setPixelSize(30);
+ p.setFont(f);
p.setPen(Qt::black);
+ if (req_size.isValid())
+ p.scale(req_size.width()/100.0, req_size.height()/50.0);
p.drawText(QRectF(0,0,100,50),Qt::AlignCenter,id);
return image;
}