i'm trying to make a chat application in QT . Is it possible to read data from the text browser of QT GUI(which shows conversations) so that i can maintain a chat history...?plz help..Thank You
Is it possible to read data from the text browser of QT GUI
4.4k Views Asked by kernel At
2
The
QTextBrowser
inheritsQTextEdit
, which works on aQTextDocument
. The QTextDocument can be converted to (and saved as) HTML usingQTextDocument::toHtml()
:I advise you to append to a log file every time a new message comes in / goes out, so update the QTextBrowser and the file "in parallel", and not saving the entire chat history everytime a new message appears.
To do so, open the log file and manually write the open
<html>
and<body>
tags without closing them. Then append the chat log entries on the still opened file. On application exit (object destruction of the chat window or whatever), close the</body>
and</html>
tags and afterwards the file itself. This will result in a much better performance than saving the whole file for every change of the QTextBrowser widget.