title: QT5 - Detecting when new files are added to a directory and retrieving their path
body: <p>My problem is relatively simple.  I have an application where I need to monitor a particular folder (the downloads folder, in my case) for <strong>added</strong> files.  Whenever a file is added to that folder, I want to move that file to a completely different directory.  I have been looking at <a href="https://doc.qt.io/qt-5/qfilesystemwatcher.html" rel="nofollow noreferrer">QFileSystemWatcher</a>; however, none of the signals it provides seems to be ideal for my situation.</p>
  <p>Here is my current code:</p>
  <pre><code>connect(&amp;m_fileWatcher, &amp;QFileSystemWatcher::directoryChanged, this, &amp;FileHandler::directoryChanged);
  
  void FileHandler::directoryChanged(const QString &amp;dir)
  {
    qDebug() &lt;&lt; &quot;File changed....&quot; &lt;&lt; string;
    // Some other logic
  }
  </code></pre>
  <p>This signal only gives me a string to work with which is the directory that witnessed a change.  I don't know what kind of change took place (add, rename, or delete), and I also have no idea which file has changed.</p>
  <p>I understand that I could store all of the files in the directory in some sort of data structure and do some other logic when this signal is emitted, but that doesn't seem very performant in this case since I'm dealing with the user's <em><strong>downloads</strong></em> folder (which could contain thousands of files).</p>
  <p><strong>How can I make this work?  Should I refer to a different helper class provided by QT, or is there some other way I can do this while utilizing QFileSystemWatcher? I'm simply just looking for ideas.</strong></p>
  <p>Thank you.</p>