Results 1 to 2 of 2

Thread: Loading images in html in a QTextBrowser

  1. #1
    Join Date
    Jun 2007
    Qt products

    Default Loading images in html in a QTextBrowser

    Hello all. I am trying to load some simple html into a QTextBrowser and display images, but the images do not load unless I specify the full path to them. I am loading the html with the following:

    QTextBrowser *textEdit;
    QFile file(fileName);
    textEdit->setHtml( file.readAll() );

    This came from QT's QTextEdit example but I changed it to use QTextBrowser instead of QTextEdit because I want links in the html.

    The following html correctly displays the image:
    <img src="d:\1.JPG" />

    The following html shows an image icon instead of the correct image:
    <img src="1.JPG" />

    The image file is in the same folder as the html file. Any ideas how to make this work without providing the full path to the image files?


  2. #2
    Join Date
    Jan 2006
    Paris, France
    Thanked 21 Times in 21 Posts
    Qt products
    MacOS X Unix/X11 Windows

    Default Re: Loading images in html in a QTextBrowser


    You can use textEdit->setSearchPaths( QStringList() << "D:\"), it specifies one or several
    directories to search content for

Similar Threads

  1. CSS + images in a QTextBrowser
    By Lykurg in forum Newbie
    Replies: 3
    Last Post: 1st February 2007, 20:58
  2. How to display images in QTextBrowser ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2007, 08:58
  3. Loading images in QTextBrowser
    By nisha0609 in forum Qt Programming
    Replies: 1
    Last Post: 3rd January 2007, 09:44
  4. getting images out of html
    By hijinks in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2006, 23:17
  5. QTextBrowser, html & pictures
    By jey in forum Qt Programming
    Replies: 3
    Last Post: 20th March 2006, 07:43


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.