PDA

View Full Version : QTextEdit and "extended ascii"



thomaspu
31st January 2008, 00:00
I've been trying to figure out how to write what I know as "extended ascii" inside a QTextEdit in such a way that I can write a few of those characters in one color, then change colors (both foreground and background colors) for the next few letters printed and so on.

extended ascii as pictured here:
http://www.asciitable.com/

All of the text that I'm inserting is using QTextEdit::insertHtml. Is there a way to insert these characters in the textEdit?

Right now I've been trying something like:
Create a HTML span tag with color attributes
insert the text I want to print, like QChar (191) for a "top-right corner". But the top right corner character doesn't show up. The characters that I'm getting match these:
http://www.idevelopment.info/data/Programming/ascii_table/PROGRAMMING_ascii_table.shtml

How do I get the first set of so called "extended ascii" chars?
Paul

wysota
31st January 2008, 00:28
The QTextEdit widget is based on Unicode and not ascii, so probably you won't succeed in achieving what you want through ascii. I suggest using css instead.

thomaspu
31st January 2008, 04:53
Actually, it turns out that it can be done. I just had to use the correct Unicode number when creating a QChar. I used the Windows Character Map to get the hex code and then converted that into decimal and created the QChar with that number. Seems to work fairly well!

Paul

wysota
31st January 2008, 09:20
As I said, you wouldn't achieve it through ascii. Using Unicode is a different story.