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 is working for changes inside too.
Forum Updated to NodeBB v4.3 + New Features

QFileSystemWatcher is working for changes inside too.

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 4 Posters 877 Views
  • 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.
  • D Offline
    D Offline
    developer_61
    wrote on last edited by developer_61
    #1

    Hello,

    i have following problem:
    I'm using the QFileSystemWatcher with fileChanged to call a function when the file is edited outside the UI. For that I'm using the connect.
    The file I'm using is an XML that is called from the QTreeView.

    So but now i have the problem if I'm going to change the Model inside the UI the function is called again. But it was planned only for changes outside the UI.

    Do you know why? And how can i solved that?

    Regards

    jsulmJ 1 Reply Last reply
    0
    • D developer_61

      Hello,

      i have following problem:
      I'm using the QFileSystemWatcher with fileChanged to call a function when the file is edited outside the UI. For that I'm using the connect.
      The file I'm using is an XML that is called from the QTreeView.

      So but now i have the problem if I'm going to change the Model inside the UI the function is called again. But it was planned only for changes outside the UI.

      Do you know why? And how can i solved that?

      Regards

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @developer_61 said in QFileSystemWatcher is working for changes inside too.:

      if I'm going to change the Model inside the UI the function is called again

      Does the model change this file? QFileSystemWatcher does not care who changes a file...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • D Offline
        D Offline
        developer_61
        wrote on last edited by
        #3

        @jsulm yes the model change the file ... :/ no option?

        jsulmJ J.HilkJ 2 Replies Last reply
        0
        • D developer_61

          @jsulm yes the model change the file ... :/ no option?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @developer_61 said in QFileSystemWatcher is working for changes inside too.:

          no option?

          I already wrote: "QFileSystemWatcher does not care who changes a file..."

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D developer_61

            @jsulm yes the model change the file ... :/ no option?

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

            @developer_61
            Like I said here:https://forum.qt.io/topic/124575/is-there-any-way-to-recognize-if-a-data-is-changed-from-outside

            keep track of when you inside your program modify the file. Then when the file system watcher notifies you, check if the times match with your last modification.
            If they do ignore the signal


            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.

            1 Reply Last reply
            2
            • D Offline
              D Offline
              developer_61
              wrote on last edited by
              #6

              @J-Hilk and what if i'm changing the file outside? it will match with my last modification again and ignore the signal ?

              J.HilkJ 1 Reply Last reply
              0
              • D developer_61

                @J-Hilk and what if i'm changing the file outside? it will match with my last modification again and ignore the signal ?

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

                @developer_61

                and what if i'm changing the file outside? it will match with my last modification again and ignore the signal ?

                why would it match with your last modification ?


                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.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  developer_61
                  wrote on last edited by developer_61
                  #8

                  @J-Hilk
                  cause if i'm editing the file outside and save it then it will trigger the function.
                  If i'm going to to edit the file inside the programm and click save inside the programm it will change my file and trigger then the function. So there is no difference between outside and inside. It will trigger the function after save.

                  J.HilkJ 1 Reply Last reply
                  0
                  • D developer_61

                    @J-Hilk
                    cause if i'm editing the file outside and save it then it will trigger the function.
                    If i'm going to to edit the file inside the programm and click save inside the programm it will change my file and trigger then the function. So there is no difference between outside and inside. It will trigger the function after save.

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

                    @developer_61

                    cause if i'm editing the file outside and save it then it will trigger the function.
                    If i'm going to to edit the file inside the programm and click save inside the programm it will change my file and trigger then the function. So there is no difference between outside and inside. It will trigger the function after save.

                    soo, working as intended ? Whats the point of this topic then?


                    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.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      developer_61
                      wrote on last edited by
                      #10

                      @J-Hilk i don't want to call the function after i change it inside. But the problem is that the change inside the programm changes the file and call the function.

                      JonBJ 1 Reply Last reply
                      0
                      • J.HilkJ Offline
                        J.HilkJ Offline
                        J.Hilk
                        Moderators
                        wrote on last edited by
                        #11

                        We're arguing in circles.

                        I'm sure you'll figure it out, good luck


                        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.

                        1 Reply Last reply
                        0
                        • D developer_61

                          @J-Hilk i don't want to call the function after i change it inside. But the problem is that the change inside the programm changes the file and call the function.

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

                          @developer_61
                          So it seems you have a couple of choices. When you change the file from inside your program:

                          • Switch off the file notification beforehand, re-enable it afterwards.

                          • Note the time at which you perform the internal update. Ignore notification for a period afterwards.

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            developer_61
                            wrote on last edited by
                            #13
                            This post is deleted!
                            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