Is there a "force" option for QFile::copy(), or an alternative library to do this?

Viewed 789

In my qt application each time my program loads I copy the latest version of some files. I noticed that QFile::copy() does not seem to allow this. In the Qt docs it says:

Note that if a file with the name newName already exists, copy() returns false (i.e. QFile will not overwrite it).

I know I can probably do something simple like:

if (QFile::exists(targetFile))
{
    QFile::remove(targetFile);
}
QFile::copy(sourceFile, targetFile);

But I am wandering if there is some clever Qt way of doing this... there usually is and I often end up not taking advantage of many Qt features because I just don't know about them.

0 Answers
Related