Results 1 to 4 of 4

Thread: QTextEdit and "extended ascii"

  1. #1
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTextEdit and "extended ascii"

    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/Pr...ii_table.shtml

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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit and "extended ascii"

    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.

  3. #3
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTextEdit and "extended ascii"

    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

  4. The following user says thank you to thomaspu for this useful post:

    pervlad (15th December 2011)

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit and "extended ascii"

    As I said, you wouldn't achieve it through ascii. Using Unicode is a different story.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.