Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change size of QPixmap?

Tags:

qt

I am write a paint program.

pix = QPixmap(600,500);  // set size to 600X500

How to change size after this? Someting like:

pix.setSize(800,600);  // Change size to 800X600
like image 399
sonichy Avatar asked Dec 16 '16 02:12

sonichy


People also ask

How to convert QImage to QPixmap?

A QPixmap object can be converted into a QImage using the toImage() function. Likewise, a QImage can be converted into a QPixmap using the fromImage(). If this is too expensive an operation, you can use QBitmap::fromImage() instead.

What is QPixmap?

The QPixmap class is an off-screen image representation that can be used as a paint device. Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture.


1 Answers

I think, QPixmap::scaled is what you need.

Returns a copy of the pixmap scaled to a rectangle with the given width and height according to the given aspectRatioMode and transformMode.

like image 114
Konstantin T. Avatar answered Nov 14 '22 15:11

Konstantin T.