[PyQt] Log viewer

Mark Summerfield mark at qtrac.eu
Fri Jan 16 15:26:42 GMT 2009


On 2009-01-16, Frédéric wrote:
> I'm using the python logging module to log everything. I would like to
> make a log viewer in my Qt application. This viewer can be opened from a
> menu, and is modal.
>
> I already did such viewer in gtk, using a textView/textBuffer. I created
> a class from textBuffer, and I added write() and flush() method, so I
> can give this object to the logging module as a handler. Then, when I
> want to display the logs, I just create the textView, set its internal
> buffer to the one I gave to logging, and so the logs appear.
>
> I would like to do the same in Qt, but I don't know how. I found a
> QTextDocument class, which sems to be the same as gtk textBuffer, but it
> does not have a appendText or appendHtml methods, nor a way to limit the
> number of entries.
>
> Any idea how I can do that?

QPlainTextEdit is optimized for use as a log display and has
appendHtml() and appendPlainText(). For Qt 4.3 or earlier use QTextEdit
or QTextBrowser instead.


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Rapid GUI Programming with Python and Qt" - ISBN 0132354187




More information about the PyQt mailing list