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
QtWS: Super Early Bird Tickets Available!

How to keep updating QTextEdit from log file

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtexteditfilesystemlog
5 Posts 2 Posters 2.7k 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.
  • F Offline
    F Offline
    firefox
    wrote on 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
  • SGaistS Offline
    SGaistS Offline
    SGaist Lifetime Qt Champion
    wrote on 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 last edited by
    #3

    Thanks. Wil try and update

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

  • Login

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