I've been looking through the documentation for QImage, and it seems like there is no way to set the size of the image other than through the constructor.
Am I blind, or is this really the case?
I've been looking through the documentation for QImage, and it seems like there is no way to set the size of the image other than through the constructor.
Am I blind, or is this really the case?
To resize an image one would use QImage::scaled(). If you want to crop an image, you can use QImage::copy() and assign it to the same object you copied from. Other ways to change the size of an image wouldn't make sense. If you need it and are willing to lose the image data, just assign an empty QImage (with a proper size and format set) to your image object.
I just wanted to check in case I missed something. What I'm actually doing is using a Qimage within a class to display different pictures, each with an arbitrary size. I was hoping I could clear the QImage, resize it and assign a new picture to it.
Instead I think I'll just create a new QImage each time with the correct size. I was hoping to be able to declare a single QImage on the stack instead of always using new, but it looks like I have no choice. Oh well.
Thanks for the reply.
No no no... Just assign a new picture and QImage will handle the rest.
Qt Code:
//...To copy to clipboard, switch view to plain text mode
Hi,
Use a QLabel for display your image, and use the following code for resize your image,
Qt Code:To copy to clipboard, switch view to plain text mode
Try this, I am sure It will help you, If you need to change the size of the picture, you just change the size of that icon ( this->size = QSize(110,102); )
![]()
Last edited by jpn; 14th December 2007 at 08:01. Reason: missing [code] tags
Bookmarks