Don't pass area.text to the functions, it gives the raw content of the TextEdit, being it plain or rich text. If your area has RichText and you want to use the plain representation of it, use :
area.getText (0, area.length)
It will give you the characters of the content, excluding the HTML formatting tags. But then you will need to do the mapping from plain text position and formatted text by yourself.
So if you need to replace 'foo' with 'foo' you will have to do it on the area.text anyway, using some RegExp or anything else.
转载:http://stackoverflow.com/questions/19265176/qml-passing-richtext-as-plaintext