I need to display a formatted text. The text is a plain text with custom markups. I need to parse the tags and display the formatted text in a window. The text will be read-only. I need to process tags like these:
- new line (not a new paragraph, just a new line within a paragraph)
- new paragraph (with and without paragraph indent)
- indented text
- coloring, italic, bold
- simple tables (bullets, "text bullets", that means, the "bullet" is a "heading" which can differ from bullet to bullet while keeping the corresponding texts equally indented). No decorations in the tables, just keep "columns".
- fixed pitch font
- detect a clicked URL, pass URL to the default web browser.
and similar simple formatting tags. The tags can be nested like this:
:color red.some red text :italic.also in italics:end of italic. continuing red text.:end of color.
I have checked the related classes in Qt and I got lost immediately. Where should I begin? What should I read or see? What widget should I select for the text window? I have QPlainTextEdit as a placeholder right now. I can display the raw text nicely but this is not what I want.


Reply With Quote
If I understand well, the QTextEdit accepts the <body> .. </body> HTML text with sufficient set of tags. Nevertheless, the original text is not HTML so that I need to translate. Okay, but I cannot append the text element by element because the intermediate text is not valid in general (missing end tags because they weren't reached so far). I need an auxiliary QString where I translate the text and then I need to display the QString as a whole. A single error in the original text can cause losing the whole output. Correct?
Bookmarks