How to move files in Qt?

Is there a cross-platform function in Qt that is equivalent to the MoveFile function in Windows and the mv command in Linux?


Sure, QDir::rename() following the old Unix / POSIX tradition of calling this rename.

Which makes sense if you think of a file with its complete path: the underlying inodes just get assigned a different path/file label.

You would use QDir::rename() but be beware of the special cases when rename() can fail:

On most file systems, rename() fails only if oldName does not exist, if newName and oldName are not on the same partition or if a file with the new name already exists. However, there are also other reasons why rename() can fail. For example, on at least one file system rename() fails if newName points to an open file.

QUrlOperator::copy() is an alternative to QDir::rename() that may also work for you.

Need Your Help

How to make object instance a hash key in Ruby?

ruby hashmap

I have a class Foo with a few member variables. When all values in two instances of the class are equal I want the objects to be 'equal'. I'd then like these objects to be keys in my hash. When I

Capturing browser logs with Selenium WebDriver using Java

java selenium selenium-webdriver

Is there a way to capture browser logs while running automated test cases with Selenium? I found an article on how to capture JavaScript errors in Selenium. But that is just for Firefox and only for