View Full Version : How to convert text to HTML in QTextEdit
Roszko
30th December 2009, 18:21
I am writing simple chat and I have simple problem. So, if I send message from client to server, this message is viewed as text but it should be viewed as HTML because in this message are HTML tags. Of course I use QTextEdit to box to display all messages. Can somebody show how Can I display text as HTML? Thanks for reply.
ComaWhite
30th December 2009, 18:23
http://doc.trolltech.com/4.6/qtextedit.html#html-prop
You can use that to get the text as html
Roszko
30th December 2009, 18:33
I have a piece of code, in variable "line" is text with html tags. I don't know how to add line in message box with converted text to html
void SimpleChatClient::receiveMessage() {
qint64 bytes = buffer->write(socket->readAll());
buffer->seek(buffer->pos() - bytes);
while (buffer->canReadLine()) {
QString line = buffer->readLine();
chat->append(line.simplified().toUtf8());
QApplication::alert(this);
}
}
numbat
31st December 2009, 07:38
Something like:
QTextCursor tc(chat->document());
tc.movePosition(QTextCursor::End);
tc.insertHtml(myHtml);
Roszko
31st December 2009, 10:16
Thank you very well, but I have another problem...
Is in QTextEdit too much messages the window isn't scrolling
is there any other method to do this with "append" method ?
numbat
31st December 2009, 10:40
The first few results:
http://www.google.com/#q=scroll+to+end+qtextedit
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.