diff options
Diffstat (limited to 'examples/declarative')
-rw-r--r-- | examples/declarative/imageprovider/imageprovider-example.qml | 3 | ||||
-rw-r--r-- | examples/declarative/imageprovider/imageprovider.cpp | 14 |
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; } |