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::fileChanged not being triggered, only once the file is closed
Forum Updated to NodeBB v4.3 + New Features

QFileSystemWatcher::fileChanged not being triggered, only once the file is closed

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 1.3k 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.
  • R Offline
    R Offline
    reonZ
    wrote on last edited by
    #1

    I am trying to monitor a file in real time while it is used by another application, but QFileSystemWatcher::fileChanged won't trigger after every changes, only once the file is closed by the application, which is when the application itself is closed.

    Is there a way for me to monitor it like i want ? i don't want to use some kind of loop constantly pulling the file data.

    J.HilkJ 1 Reply Last reply
    0
    • R reonZ

      I am trying to monitor a file in real time while it is used by another application, but QFileSystemWatcher::fileChanged won't trigger after every changes, only once the file is closed by the application, which is when the application itself is closed.

      Is there a way for me to monitor it like i want ? i don't want to use some kind of loop constantly pulling the file data.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @reonZ
      that is actually not unexpected. Most file (ReadWrite-Systems) only actually write to the file when you close it or explicitly call flush()


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      R 1 Reply Last reply
      4
      • J.HilkJ J.Hilk

        @reonZ
        that is actually not unexpected. Most file (ReadWrite-Systems) only actually write to the file when you close it or explicitly call flush()

        R Offline
        R Offline
        reonZ
        wrote on last edited by
        #3

        @J.Hilk But it is flushed after each add though, i can manually check changes using visual code and see lines being added while the other application is running, just that (on window at least), QFileSystemWatcher::fileChanged does not trigger until the file is closed.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Which platform ?

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          R 1 Reply Last reply
          1
          • dheerendraD dheerendra

            Which platform ?

            R Offline
            R Offline
            reonZ
            wrote on last edited by
            #5

            @dheerendra Windows 10 64bit

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              Seems to be a long standing issue/ implementation limitation.
              https://bugreports.qt.io/browse/QTBUG-41119

              R 1 Reply Last reply
              4
              • mrjjM mrjj

                Hi
                Seems to be a long standing issue/ implementation limitation.
                https://bugreports.qt.io/browse/QTBUG-41119

                R Offline
                R Offline
                reonZ
                wrote on last edited by
                #7

                @mrjj Yeah sadly i have read that and hoped there was an alternative.

                Well i decided to use QTimer and read only from the last position i was at last iteration.
                Since this is a log file, i don't have to worry about modified or deleted data, it can only be added lines.

                1 Reply Last reply
                1

                • Login

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