Why QDir::rmdir is not static?

589 views Asked by At

QFile has a static function

bool QFile::remove ( const QString & fileName ) [static]

which deletes the specified file. This is handy: we have a path to file, and we use a command to remove it. However, QDir does not have such command, only this one:

bool QDir::rmdir ( const QString & dirName ) const

which is non-static and hence demands an object. So I'm forced to do ugly things like

QDir().rmdir(path)

This is disgusting. Am I missing something?

1

There are 1 answers

0
Marcus On

You can derive the class QDir and add your static method.

 class MyQDir : public QDir {
      // Define constructors/destructor

      static bool remove ( const QString & dirName ) {
            return QDir().rmdir(dirName);
      }
 };