[SOLVED]save a png file
Hello,
In my application I create a png file and save it in a directory (named result.png). I want to get this image without using a dialog box from this directory and then save it in an other directory using a dialog box.How could this be done? I hope someone could help.
6 replies
a combination of QFile :: copy [doc.qt.nokia.com] and QFileDialog [doc.qt.nokia.com] will do the trick.
So let me see if I got this correct. You create an Image and save it in some directory as result.png and then you want to copy it to another directory, while the user can choose the directory with a file dialog (QFileDialog::getExistingDirectory [doc.qt.nokia.com]). To copy, you can either use QFile::copy or just open one file, read it into a QByteArray (I would suggest to adjust the size of the read depending on memory and harddrive sector size) and write that back to a different file.
To copy an image from one directory to another should be something like the following code. But I want to copy two files for 3D images (.hdr, .img), which are located in the same directory. How I could copy these both two image files in an other directory by using the same QFileDialog for saving images?
- void MainWindow::save()
- {
- this,
- tr("Save image"),
- tr("Image (*.img)") );
- }
You must log in to post a reply. Not a member yet? Register here!





