PDA

View Full Version : QTextDocument and HTML tags



naga
12th December 2011, 20:22
Hi,

I have a QTextDocument (in an QTextEdit) that contains HTML formatted text. Based on the enclosing tag (if any) I need to perform different tasks when the user presses the enter key.

How can I get the enclosing tag?

/Regards

ChrisW67
13th December 2011, 05:23
I assume you mean the text visible to the user is HTML.

A naive approach: Look backward for the most recent open tag (if any), look forward for the next close tag (if any), if you have two tags and they match then you have your answer.

Were you expecting a Qt supplied findTheEndTagIfAny() function?

naga
13th December 2011, 11:22
Hi,

no I mean that the user visible text is formatted using HTML but shown as in a WYSIWYG editor.

However if this means that the text that I can access contains the tags then it will be easy. But I kinda assumed that the html is converted into some formatting hidden inside some propertied associated with the different blocks/frames.

/Regards