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
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
QTextBrowserinheritsQTextEdit, 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.