[SOLVED] remove html from the textEdit widget?
-
when i send a blank message from server to client textEdit, i get the following message displayed. i have tried removing that extra line brakes without any luck. I have tried QRegExp, <br> <p> but they do not works. how to remove this extra garbage from the textEdit widget and without using toPlainText?
here is the garbage ---------------------------
User:
User:
User: p, li { white-space: pre-wrap; }
User:User:
the client sends to the server the message in UTf8 and returns it the same way. when i get the message back, i get the garbage above. when the server gets the message, a bunch of html entities are displayed.
@QString message = ui->sayLineEdit->toHtml().trimmed();
socket->write(QString(message + "\n").toUtf8());@ -
[quote author="kalster" date="1313883400"]i have tried removing that extra line brakes without any luck. I have tried QRegExp, <br> <p> but they do not works.
[/quote]
What did you try? Post code. What did not work? Post results and/or error messages.[quote author="kalster" date="1313883400"]
how to remove this extra garbage from the textEdit widget and without using toPlainText?
[/quote]
Actually, .toPlainText() sounds very much like what you need. Why not use it? Can't you make a hidden copy of the text edit and use .toPlainText() there, if nothing else helps?[quote author="kalster" date="1313883400"]
the client sends to the server the message in UTf8 and returns it the same way. when i get the message back, i get the garbage above. when the server gets the message, a bunch of html entities are displayed.
[/quote]
You are in control of the messages, it seems. Why do you send the garbage in the first please? You could just not send it? It looks you specifically send it as HTML, which might not make sense. Can't you just do
@
QString message = ui->sayLineEdit->toPlainText().trimmed();
@
?[quote author="kalster" date="1313883400"]
p, li { white-space: pre-wrap; }
[/quote]
If this is your garbage, you can use
@
message.replace("p, li { white-space: pre-wrap; }", "");
@
to remove it. -
i have a client and server. i am using textedit because i want html in the code. when the client sends the formatted code to the server, the server displays all the html in the message including the <html> and <body>, styles, ect, as in the code below.
@QString message = ui->sayLineEdit->toHtml().trimmed();
socket->write(QString(message + "\n").toUtf8());@if i do toPlainText then the user has no bold in the text. I need html in there but not the extra html that i get after the message is sent to the server..
QString message = ui->sayLineEdit->toPlainText().trimmed();
the server reads the message from the client and the code is here...
@ QString line = QString::fromUtf8(client->readLine()).trimmed();@ -
does anyone have another method to read and write to the server. the method i am using create garbage in the message.
I am trying the use mid to remove the garbage at the beginning of the client output message but its not working. all of the message length is displayed, yet i have mid set to 40. below is the code.
@@QString message = ui->sayLineEdit->toHtml().trimmed();
message == message.mid(40,-1);@
-