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.
  • timmie124T timmie124

    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 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.

    timmie124T 1 Reply Last reply
    0
    • ? A Former User

      @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.

      timmie124T Offline
      timmie124T Offline
      timmie124
      wrote on last edited by
      #7

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

      ? 1 Reply Last reply
      0
      • timmie124T timmie124

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

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #8

        @timmie124 :-)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          michelson
          wrote on last edited by
          #9

          Mayby just QApplication::processEvents()?

          ? 1 Reply Last reply
          0
          • M michelson

            Mayby just QApplication::processEvents()?

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #10

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

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 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

              kshegunovK 1 Reply Last reply
              0
              • Paul ColbyP Offline
                Paul ColbyP Offline
                Paul Colby
                wrote on last edited by
                #12

                I'd suggest QFileSystemWatcher too.

                1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi,

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

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on 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

                  Paul ColbyP 1 Reply Last reply
                  0
                  • kshegunovK kshegunov

                    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.

                    Paul ColbyP Offline
                    Paul ColbyP Offline
                    Paul Colby
                    wrote on 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.

                    kshegunovK 1 Reply Last reply
                    0
                    • Paul ColbyP Paul Colby

                      @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.

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on 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

                      • Login

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