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. ifstream crashes ui?
Forum Updated to NodeBB v4.3 + New Features

ifstream crashes ui?

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 6 Posters 4.1k Views 5 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.
  • T Offline
    T Offline
    timmie124
    wrote on 23 May 2016, 19:02 last edited by
    #5

    so do I just need to put this code into another thread and it wont lock up the UI?

    https://gyazo.com/3c21a23cfe27f289b30aa35905ff749b QT
    https://gyazo.com/7e5ffdd79d369009075a70af4247a7f2 VS2013

    ? 1 Reply Last reply 23 May 2016, 19:07
    0
    • T timmie124
      23 May 2016, 19:02

      so do I just need to put this code into another thread and it wont lock up the UI?

      https://gyazo.com/3c21a23cfe27f289b30aa35905ff749b QT
      https://gyazo.com/7e5ffdd79d369009075a70af4247a7f2 VS2013

      ? Offline
      ? Offline
      A Former User
      wrote on 23 May 2016, 19:07 last edited by
      #6

      @timmie124 said:

      so do I just need to put this code into another thread

      That would be the easiest solution, yes. But you could also use a timer and look for new lines in the file every few milliseconds.

      T 1 Reply Last reply 23 May 2016, 19:08
      0
      • ? A Former User
        23 May 2016, 19:07

        @timmie124 said:

        so do I just need to put this code into another thread

        That would be the easiest solution, yes. But you could also use a timer and look for new lines in the file every few milliseconds.

        T Offline
        T Offline
        timmie124
        wrote on 23 May 2016, 19:08 last edited by
        #7

        @Wieland I'll give it a shot thank you!

        ? 1 Reply Last reply 23 May 2016, 19:09
        0
        • T timmie124
          23 May 2016, 19:08

          @Wieland I'll give it a shot thank you!

          ? Offline
          ? Offline
          A Former User
          wrote on 23 May 2016, 19:09 last edited by
          #8

          @timmie124 :-)

          1 Reply Last reply
          0
          • M Offline
            M Offline
            michelson
            wrote on 23 May 2016, 19:50 last edited by
            #9

            Mayby just QApplication::processEvents()?

            ? 1 Reply Last reply 23 May 2016, 20:26
            0
            • M michelson
              23 May 2016, 19:50

              Mayby just QApplication::processEvents()?

              ? Offline
              ? Offline
              A Former User
              wrote on 23 May 2016, 20:26 last edited by
              #10

              @michelson Yeah but then usage on one CPU core will stay at 100%.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 23 May 2016, 22:00 last edited by
                #11

                Hi,

                To add to @Wieland the QSocketNotifier class might be of interest for your use case.

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

                K 1 Reply Last reply 23 May 2016, 23:24
                0
                • P Offline
                  P Offline
                  Paul Colby
                  wrote on 23 May 2016, 22:28 last edited by
                  #12

                  I'd suggest QFileSystemWatcher too.

                  1 Reply Last reply
                  0
                  • S SGaist
                    23 May 2016, 22:00

                    Hi,

                    To add to @Wieland the QSocketNotifier class might be of interest for your use case.

                    K Offline
                    K Offline
                    kshegunov
                    Moderators
                    wrote on 23 May 2016, 23:24 last edited by
                    #13

                    I'm with @SGaist, QSocketNotifier is appropriate for such things. QFileSystemWatcher will watch for changes in attributes or directory structure, but I don't believe it actually notifies on content changes, but I might be wrong.

                    Read and abide by the Qt Code of Conduct

                    P 1 Reply Last reply 23 May 2016, 23:40
                    0
                    • K kshegunov
                      23 May 2016, 23:24

                      I'm with @SGaist, QSocketNotifier is appropriate for such things. QFileSystemWatcher will watch for changes in attributes or directory structure, but I don't believe it actually notifies on content changes, but I might be wrong.

                      P Offline
                      P Offline
                      Paul Colby
                      wrote on 23 May 2016, 23:40 last edited by
                      #14

                      @kshegunov said:

                      QFileSystemWatcher will watch for changes in attributes or directory structure, but I don't believe it actually notifies on content changes, but I might be wrong.

                      QFileSystemWatcher::fileChanged says:

                      This signal is emitted when the file at the specified path is modified, renamed or removed from disk.

                      It does detect file content changes on Windows (using FindFirstChangeNotification and friends) and on Linux (using inotify). It also has OSX and BSD implementations too, but I haven't looked into how they work.

                      QSocketNotifier might be the better option, but I'd certainly consider both. It would be an interesting exercise to put together a minimal example of both options to compare their subtleties :)

                      Cheers.

                      K 1 Reply Last reply 23 May 2016, 23:54
                      0
                      • P Paul Colby
                        23 May 2016, 23:40

                        @kshegunov said:

                        QFileSystemWatcher will watch for changes in attributes or directory structure, but I don't believe it actually notifies on content changes, but I might be wrong.

                        QFileSystemWatcher::fileChanged says:

                        This signal is emitted when the file at the specified path is modified, renamed or removed from disk.

                        It does detect file content changes on Windows (using FindFirstChangeNotification and friends) and on Linux (using inotify). It also has OSX and BSD implementations too, but I haven't looked into how they work.

                        QSocketNotifier might be the better option, but I'd certainly consider both. It would be an interesting exercise to put together a minimal example of both options to compare their subtleties :)

                        Cheers.

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 23 May 2016, 23:54 last edited by kshegunov
                        #15

                        @Paul-Colby

                        It does detect file content changes on Windows (using FindFirstChangeNotification and friends)

                        Well, MSDN doesn't mention a notification for the file being written as far as I could see, beside perhaps the size change or the last write time attribute. I don't know how responsive those are, but I suppose QFileSystemWatcher is a fair try.

                        It would be an interesting exercise to put together a minimal example of both options to compare their subtleties

                        Indeed.

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0

                        14/15

                        23 May 2016, 23:40

                        • Login

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