Is it possible to export images generated in Qt creator? The qimage which is a built in data type in Qt. We modify it using setpixel()
function. I want to save that image for further use.
Asked
Active
Viewed 1.8k times
2

Thomas Ayoub
- 29,063
- 15
- 95
- 142

Animesh Karnewar
- 416
- 1
- 8
- 17
1 Answers
12
You can use
bool QImage::save ( const QString & fileName, const char * format = 0, int quality = -1 ) const
To save your QImage
Saves the image to the file with the given fileName, using the given image file format and quality factor. If format is 0, QImage will attempt to guess the format by looking at fileName's suffix.
The quality factor must be in the range 0 to 100 or -1. Specify 0 to obtain small compressed files, 100 for large uncompressed files, and -1 (the default) to use the default settings.
Returns true if the image was successfully saved; otherwise returns false.

Community
- 1
- 1

Thomas Ayoub
- 29,063
- 15
- 95
- 142
-
If the method returns false, is there a diagnostic that tells you what the problem was? – Richard Jessop Jan 30 '19 at 15:25
-
1@RichardJessop I would change a bit the structure and call [`QImageWriter::errorString`](http://doc.qt.io/qt-5/qimagewriter.html#errorString) – Thomas Ayoub Jan 30 '19 at 17:27