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. QFileSystemWatcher new file added
Qt 6.11 is out! See what's new in the release blog

QFileSystemWatcher new file added

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.7k 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
    abdullahzubair109
    wrote on last edited by
    #1

    How can I trigger a signal with new filename added to a directory using QFileSystemWatcher

    JonBJ 1 Reply Last reply
    0
    • A abdullahzubair109

      How can I trigger a signal with new filename added to a directory using QFileSystemWatcher

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @abdullahzubair109
      https://doc.qt.io/qt-5/qfilesystemwatcher.html#directoryChanged ?

      A 1 Reply Last reply
      2
      • JonBJ JonB

        @abdullahzubair109
        https://doc.qt.io/qt-5/qfilesystemwatcher.html#directoryChanged ?

        A Offline
        A Offline
        abdullahzubair109
        wrote on last edited by abdullahzubair109
        #3

        @JonB no... It will return the directory where new file added or renamed or removed.. Not the path for newly added file.. Correct me if I am wrong

        JonBJ 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          If you need that level of details, may QFileSystemModel would be more interesting. You can use the rowsInserted signal to grab the information you are after.

          Otherwise, you should keep a list of the entries of the folder you are watching in order to compare it to it's new content when directoryChanged is called.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • A abdullahzubair109

            @JonB no... It will return the directory where new file added or renamed or removed.. Not the path for newly added file.. Correct me if I am wrong

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @abdullahzubair109
            QFileSystemWatcher::directoryChanged signal is as good as it gets :) You have to figure out what got added. I'm not sure whether @SGaist is saying QFileSystemModel::rowsInserted can be used to automatically monitor changes in the background.

            1 Reply Last reply
            0

            • Login

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