Move directory using Qt

I want to move a directory. My selected directory contains many sub directories and files.

How can I implement the same using Qt?

Upvotes: 9

Views: 8340

Answers (1)

Reto ODT
Reto ODT

Reputation: 351

QDir::rename does it in the most cases. Following example moves theDir incl content from source to dest:

QString original = "/home/test/source/theDir";
QString dest = "/home/test/temp";
QDir dir;
if( !dir.rename( original, dest ) ){
  throw Exception( "move failed" );
}

Upvotes: 18

Related Questions