QTextEdit and inserting HTML
	
	
		I have a QPlainTextEdit widget that I insert HTML into via moving the cursor along.
What I have noticed is that if there are things that are in < > tags but are NOT valid html elements, then QPlainTextEdit seems to fail.
	Code:
	
QString txt 
= "You have the following commands: <br />read <#/next>, note <title>, remove #, list <from #/last>, marker <#/reset>";
 
 
When do the following
	Code:
	
ui->txtOutput->textCursor().insertHtml(txt);
ui->txtOutput->setTextCursor(prevCursor);
 
I get the following showing up in the QPlainTextEdit widget
You have the following commands:
read , note
Is is possible to some how.. have QPlainTextEdit ignore non-valid HTML elements? Then again, I'm not 100% sure this is my issue, but it seems iike it so far.
(on a side note, is there a [pre] for things that are not code?)
	 
	
	
	
		Re: QTextEdit and inserting HTML
	
	
		You want it to ignore invalid  html tags but still respect valid ones? If so then you have to preprocess your text and replace all angle brackets with html entities.
	 
	
	
	
		Re: QTextEdit and inserting HTML
	
	
		See http://qt-project.org/doc/qt-4.8/qt.html#escape for a helper function that escapes HTML entities
Cheers,
_
	 
	
	
	
		Re: QTextEdit and inserting HTML
	
	
		
	Quote:
	
		
		
			
				Originally Posted by 
anda_skoa
				
			 
			
			
		
	 
 That was the key! Thanks! Now my MUD client supports ansi colours properly as it converts them to html for the QPlainTextEdit.