Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDir remove function
Forum Updated to NodeBB v4.3 + New Features

QDir remove function

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 687 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Allman 2
    wrote on 17 Feb 2018, 23:31 last edited by Allman 2
    #1

    Hello QT- Developer,

    so in my HOME-Dir exist a folder which content should be deleted.

    It works fine when I debug through the code, but without debugging all files still exist.
    Well I have no idea why? Do you have some advice?

    Code:
    QStringList list;
    list << ".png" << ".jpg" << ".gif" << ".svg";
    QDir dir(path);
    dir.setNameFilters(list);
    dir.setFilter(QDir::Files);
    foreach(QString dirFile, dir.entryList())
    {
    dir.remove(dirFile);
    }

    THX ;)

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Paul Colby
      wrote on 18 Feb 2018, 04:51 last edited by Paul Colby
      #2

      Hi @Allman-2,

      How is path being set? I would think its more likely an issue with that than the code you've shown... but that's just a guess.

      First thing I'd do is add some debugging. Something like:

      qDebug() << QDir::currentPath()
      qDebug() << path;
      QDir dir(path);
      qDebug() << dir.absolutePath();
      dir.setNameFilters(list);
      dir.setFilter(QDir::Files);
      foreach(QString dirFile, dir.entryList())
      {
          qDebug() << dirFile;
          const bool removed = dir.remove(dirFile);
          qDebug() << removed;
      }
      

      Cheers.

      1 Reply Last reply
      3
      • A Offline
        A Offline
        Allman 2
        wrote on 18 Feb 2018, 12:59 last edited by
        #3

        Hello,
        yes now I got the answer, because at that time the QDir is created there is now contend in
        this Path. There is a delay time.

        THX t all:

        1 Reply Last reply
        0

        1/3

        17 Feb 2018, 23:31

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved