Qt World Summit: Submit your Presentation

Handle doctype and other html/xml tags inside message - Qt

  • Hi all,

    I have got an issue here.

    I am creating a text message something like "Are you :) today?". Since this contains a smiley, i convert this message text to html get the smiley mapping and then display. But this has a problem. All the html tags are working in the message now. For e.g. if the message starts with "<!" characters which comments the whole text line in html is working and all those possible combinations.

    What can i do to fix this issue. I just want to show the text message as typed by the user except when the smilies are present in the message.

  • Try to run a regexp and escape all those special chars. Anyway, only a subset of HTML tags work in Qt rich text box.

  • do I need to escape those?

    for e.g

    <!This is cool ------ this text should be displayed as it is but right now this shows blank in QLabel text. And removing them is not the solution. Do you have any such regexp btw

  • You could use rich text documents for displaying such tags (but they will be interpreted as HTML tags):


    For regexp in Qt try to search some examples.

Log in to reply