Results 1 to 2 of 2

Thread: QTextEdit format html code

  1. #1
    Join Date
    Jul 2012
    Posts
    17
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default QTextEdit format html code

    Hi community,

    is it possible with qtextedit (or any other text viewer/editor like qtextbrowser) to format html code?

    I mean like that:
    Qt Code:
    1. textedit->textCursor().insertHtml("<i><b>");
    2. textedit->textCursor().insertText("<img src='image.jpg' />");
    3. textedit->textCursor().insertHtml("</i></b>");
    To copy to clipboard, switch view to plain text mode 
    This should be the output:
    <img src='image.jpg' />

    Of course it doesnt work, the output is:
    <img src='image.jpg' />

    How to achieve that html code ist displayed as plaintext but also formatted (well then it wouldn't be plaintext)?

  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 format html code

    Set the document to plain text mode and use QTextFormat and family to format it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Edder (16th July 2012)

Similar Threads

  1. can't get format under cursor of a QTextEdit
    By dvirtz in forum Qt Programming
    Replies: 4
    Last Post: 1st November 2011, 12:12
  2. Problem with Qtextedit format - hex viewing
    By daro21 in forum Qt Programming
    Replies: 1
    Last Post: 6th June 2011, 19:18
  3. Support for .rtf format in QTextDocument or QTextEdit?
    By LynneV in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2010, 23:01
  4. problem displaying html code in QTextEdit
    By mourad in forum Qt Programming
    Replies: 2
    Last Post: 7th September 2009, 09:25
  5. QPrinter::PdfFormat html format && Link
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 8th April 2007, 12:37

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.