Results 1 to 3 of 3

Thread: put html text into a qtextedit

  1. #1
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question put html text into a qtextedit

    How can i put a local file including htm3 text into QTextedit???

    I have an object of type QFile handling my local file....I'd like to have

    QFILE----->QTEXTEDIT............!!!!!!!!!!!!!
    Last edited by dreamer; 4th May 2008 at 17:43. Reason: updated contents

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: put html text into a qtextedit

    The QFile is of no use here.
    Read the markup from the file using a QTextStream and set it in the QTextEdit using QTextEdit::setHtml.

  3. #3
    Join Date
    Apr 2008
    Posts
    104
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: put html text into a qtextedit

    A simplified example:

    Qt Code:
    1. QFile file (fileName);
    2. if (! file.open(QFile::ReadOnly | QFile::Text))
    3. return;
    4.  
    5. QTextStream in(&file);
    6. in.setCodec("UTF-8");
    7.  
    8. textEdit->setPlainText(in.readAll());
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 12th May 2008 at 13:31. Reason: missing [code] tags

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  3. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  4. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03
  5. [Qt 4.1]using html in QTextEdit from designer
    By patcito in forum Qt Programming
    Replies: 5
    Last Post: 16th January 2006, 22:36

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.