I wish to use QImage in Qt to load and save images. While I can load an image, for whatever reason it wont let me save the image.
So I started writing a simple code, made a simple png test file using paint, put it into the same folder as the project itself.
#include <QImage>
#include <iostream>
int main(){
QImage image;
image.load("test.png");
if (image.isNull()){
std::cout << "ERROR!\n";
}
else{
std::cout << "IMAGE LOADED!\n";
}
image.save("test1.png");
return 0;
}
During running the program I get the message of "IMAGE LOADED!" from the application output, however when I check the folder I expect the same image saved as test1.png, which doesn't appear at all.
So, how do I actually save an image? What did I miss?
In the other comments mentioned the image got saved into the working directory, which is not the same as the folder where the project is located.
In my specific case I got the image by adding a full path to the project like
to find the image.
Ideally I should directly access with the working directory.