Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved How to keep updating QTextEdit from log file

    General and Desktop
    qtextedit filesystem log
    2
    5
    2413
    Loading More Posts
    • 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.
    • F
      firefox last edited by

      I have a log file that keeps on growing. I want the QTextEdit to show the progress in log like tail -f command. I'm using pyqt

      i've tried this
      self.logpath = os.path.join(os.getcwd(), logfolder, fec_log.txt)
      fs_watcher= QFileSystemWatcher()
      fs_watcher.addPath(self.logpath)
      fs_watcher.fileChanged.connect(self.logWatcher)

      def logWatcher(self):
      file = open(logpath)
      self. textedit.append(file.readline())

      i know this has a problem that it wouldn;t actually seem like streaming the logfile but it keeps reloading the file. But even that doesnt happen. logWatcher slot doesn get called, What could be the problem

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        IIRC, QSocketNotifier is a better choice for such activities

        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 Reply Quote 0
        • F
          firefox last edited by

          Thanks. Wil try and update

          1 Reply Last reply Reply Quote 0
          • F
            firefox last edited by

            Hi,

            I'm lost here. I'm on windows. How do i get the socket fd which is required argument for QSocketNotifier().

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              Using QFile::handle

              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 Reply Quote 0
              • First post
                Last post