Search code examples
qtdirectorymove

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?


Solution

  • 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" );
    }