Results 1 to 3 of 3

Thread: QTextBrowser and html

  1. #1
    Join Date
    Oct 2008
    Location
    Thodupuzha, a small town in kerala
    Posts
    31
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QTextBrowser and html

    Sir,

    I am trying to use html in QTextBrowser..I have a Html file in my filesystem...
    I am trying to print that on a QTextBrowser....But I cant...

    This is the code that I used..
    Qt Code:
    1. QTextBrowser * browser;
    2. browser=new QTextBrowser(frame);
    3. QFile file(filename);
    4. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    5. {
    6. qWarning("file not found");
    7. return;
    8. }
    9. while (!file.atEnd())
    10. {
    11. QByteArray line = file.readLine();
    12. browser->setHtml(QString(line));
    13. }
    To copy to clipboard, switch view to plain text mode 

    What am i missing....
    Last edited by jpn; 6th July 2009 at 20:20. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTextBrowser and html

    Hi,

    to use code in your post use "[" instead of "<". Second setHtml() does not append, it overwrite the whole html content, so better use:
    Qt Code:
    1. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    2. {
    3. qWarning("file not found");
    4. return;
    5. }
    6. browser->setHtml(file.readAll());
    To copy to clipboard, switch view to plain text mode 
    Third, we also have a Newbie section at this board. Just in case...

  3. #3
    Join Date
    Oct 2008
    Location
    Thodupuzha, a small town in kerala
    Posts
    31
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTextBrowser and html

    Thank you lykurg...I am sorry if I put my thread in a wrong forum...Sorry about that..........

Similar Threads

  1. Special character's HTML entity to string
    By Hiba in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2009, 14:05
  2. How to disply Simplified Chinese in QTextBrowser
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 21st April 2008, 08:15
  3. GIF or MNG images for use in html for QTextBrowser
    By manojmka in forum Qt Programming
    Replies: 3
    Last Post: 2nd January 2008, 16:30
  4. Loading images in html in a QTextBrowser
    By BasicPoke in forum Newbie
    Replies: 1
    Last Post: 6th June 2007, 21:51
  5. QTextBrowser, html & pictures
    By jey in forum Qt Programming
    Replies: 3
    Last Post: 20th March 2006, 07:43

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
  •  
Qt is a trademark of The Qt Company.