QTextBlock with a prefix and a suffix
I want to insert a QTextBlock which has a prefix and a suffix, just as in a QTextList but without a number or bullet or something. It has to be part of the QTextBlock and may not be removed with backspace/delete.
A QTextList seems to put the prefix and suffix in the margins before and after the list item using a QTextLayout to draw on the paintDevice of the private QTextDocumentLayout. I have tried using this piece of code in my program, but I can't use the painDevice of the QTextDocumentLayout outside the QTextDocumentLayout.
I'm also working on a QTextObjectInterface and have already had some result for the prefix, although it doesn't look very nice if the editable contents of the QTextBlock changes.
So, I'm looking for some hints on the subject.
- Is is possible to create a custom QTextList class with QTextListFormat::ListStyleUndefined and a prefix and suffix?
- Is the QTextObjectInterface the way to go and does someone know a more detailed example than the Text Object Example?
- Could QTextLayout::setPreeditArea be a better approach and is there some example of it's usage?
To be more exact, I want to place a "(" and a ")" at the beginning and the end of the QTextBlock. While I can place one of those with QTextLayout->setPreeditArea(0 , "("), it seems I can not place both of them. Also, While the "(" remains in place while deleting some of the characters, the textCursor can still be placed on position 0 where the preeditText is.
Whem using a QTextList, a prefix and suffix can not be used with QTextListFormat::ListStyleUndefined.
Someone an idea or a better approach?