Function declaration: void qpainter: drawimage (const qrectf & target, const qimage & image, const qrectf & source, QT: imageconversionflags flags = QT: autocolor)
Example:
Qrectf target (10.0, 20.0, 80.0, 60.0); // create a target rectangle
Qrectf source (0.0, 0.0, 70.0, 40.0); // create a source rectangle to specify the part to be displayed in the source Image File
Qimage image (":/images/myimage.png"); // create a qimage Class Object Image
Qpainter painter (this );
Painter. drawimage (target, image, source); // draw an image from the source image file (0.0, 0.0, 70.0, 40.0) to the painter device.
// (10.0, 20.0, 80.0, 60.0) position, adaptive size
1: void ImageWidget::paintEvent(QPaintEvent *event) {
2: QPainter painter(this);
3: QRectF target(0, 0, this->width(), this->height());
4: if(!img.isNull())
5: painter.drawImage(target,img);
6: //painter.drawImage(0,0,img);
7: //img.save("test.bmp");
8: }