Results 1 to 2 of 2

Thread: Loading images in html in a QTextBrowser

  1. #1
    Join Date
    Jun 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    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:
    <html>
    <img src="d:\1.JPG" />
    </html>

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

    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?

    Thanks
    BasicPoke

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Loading images in html in a QTextBrowser

    Hello,

    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, 21:58
  2. How to display images in QTextBrowser ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2007, 09:58
  3. Loading images in QTextBrowser
    By nisha0609 in forum Qt Programming
    Replies: 1
    Last Post: 3rd January 2007, 10:44
  4. getting images out of html
    By hijinks in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2006, 00:17
  5. QTextBrowser, html & pictures
    By jey in forum Qt Programming
    Replies: 3
    Last Post: 20th March 2006, 08: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.