If I want to load file directly (QImage i1("image1.jpg");) where should I store it?
If I have to give full path of file or only short path is required?
If you don't want to worry about an image (and you are not having too much of them), consider using Qt Resources. Qt Resources will embed the image into the executable independent of the platform. The images would be pulled from the filesystem at compile time, and an IDE like Qt Creator actually helps you with that.
E.g. if you created an resource called "image" containing your file, you could reference your image by typing
QImage(":/images/image1.jpg")
If you want to use QImage as you have written in your question, then your image needs to be in your current directory. Most likely that will be the directory where your executable is stored.
Otherwise you will have to give either a relative or full path.
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