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
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With