Will QFile :: copy create create a copy of a file or move content from one file to another?

I am trying to copy a file from one place to another (on the device) using C ++ / Qt

I tried QFile :: copy ("path1 / file", "path2");

I want to copy a file in path1 to path2. path2 has no file.

I just want to know if this is correct, because this code does not seem to work.

Also, should I open the file before trying to copy? Help is needed!

+5
source share
1 answer

If you want to copy path1/filein path2with the same file name, you will want to do:

QFile::copy("path1/file", "path2/file");

Copy allows you to change the file name. Example:

QFile::copy("path1/file1", "path1/file2");

. , . , . QFile::rename() .

+10

All Articles