Hi!
I have a syntax highlighted QTextEdit. Is there a way to get the information: font,color..
out of the QTextDocument for each character.
So I want to get this information out of the editor->document ().
Is that possible.
Thanks.
Hi!
I have a syntax highlighted QTextEdit. Is there a way to get the information: font,color..
out of the QTextDocument for each character.
So I want to get this information out of the editor->document ().
Is that possible.
Thanks.
Are you using QSyntaxHighlighter?
you can query the current formatting and user data using the format()
J-P Nurmi
kemp (24th January 2007)
Thank you for your answer. Does that mean that I still need QTextEdit to aces the highlighter,
or is there a way to do that through the document alone?
Could you please explain the task? For what do you actually need all the colors?
For syntax highlighting purpose, QSyntaxHighlighter can do those pretty handy; format() & setFormat().
If you really need to manually extract the same information, I think you should first retrieve the corresponding QTextBlock, then construct a QTextCursor for it, move it to the correct position and then ask for it's format.
J-P Nurmi
I have a print preview. I get the document and in paintevent I iterate through the textblocks and through text in each textblock. Now I want to make everything in color like there is in texteditor that i highlighted with the syntaxhighlighter.
Maybe you could get away with calling QTextDocument::drawContents() with a painter having a suitable scaling? That's just an idea, I don't know if it would work as desired..
J-P Nurmi
Thanks for your help.
Bookmarks