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. How to keep updating QTextEdit from log file
Forum Updated to NodeBB v4.3 + New Features

How to keep updating QTextEdit from log file

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtexteditfilesystemlog
5 Posts 2 Posters 3.0k 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.
  • F Offline
    F Offline
    firefox
    wrote on 5 Apr 2016, 15:10 last edited by
    #1

    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
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 5 Apr 2016, 20:55 last edited by
      #2

      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
      0
      • F Offline
        F Offline
        firefox
        wrote on 6 Apr 2016, 06:55 last edited by
        #3

        Thanks. Wil try and update

        1 Reply Last reply
        0
        • F Offline
          F Offline
          firefox
          wrote on 6 Apr 2016, 15:05 last edited by
          #4

          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
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 6 Apr 2016, 20:37 last edited by
            #5

            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
            0

            4/5

            6 Apr 2016, 15:05

            • Login

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