Results 1 to 9 of 9

Thread: Why the images from the HTML file is not loaded??

  1. #1
    Join Date
    Jan 2011
    Posts
    42
    Thanks
    8
    Qt products
    Qt4 Qt/Embedded

    Default Why the images from the HTML file is not loaded??

    Am trying to insert the HTML file in the TextEdit !! After inserting, only the Texts and Links are being loaded in the TextEdit widget. Why the images are not loaded ???

  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: Why the images from the HTML file is not loaded??

    Maybe the path (href) is not valid. Or try to embed them. See the wiki article I have wrote long time ago: [WIKI]QTextBrowser with images and CSS[/WIKI] (It might be not any more state of the art, but should still work.)

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

    rleojoseph (1st March 2011)

  4. #3
    Join Date
    Jan 2011
    Posts
    42
    Thanks
    8
    Qt products
    Qt4 Qt/Embedded

    Default Re: Why the images from the HTML file is not loaded??

    Thanks sir, But am trying to insert a saved html file in the TextEdit !

  5. #4
    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: Why the images from the HTML file is not loaded??

    How are the href defined? You can alter the HTML files and add a "base href" or still load the images to the resource file.

  6. #5
    Join Date
    Jan 2011
    Posts
    42
    Thanks
    8
    Qt products
    Qt4 Qt/Embedded

    Default Re: Why the images from the HTML file is not loaded??

    am using the following code
    Qt Code:
    1. QFile inputFile(filename);
    2. inputFile.open(QIODevice::ReadOnly);
    3. QTextStream in(&inputFile);
    4. QString line = in.readAll();
    5. //in.setCodec("UTF-8");
    6. inputFile.close();
    7. QTextCursor cursor=textEdit->textCursor();
    8. cursor.insertHtml(line);
    To copy to clipboard, switch view to plain text mode 

  7. #6
    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: Why the images from the HTML file is not loaded??

    ...and? It probably would be helpful if you post an example of the actual HTML you are about to insert.

  8. #7
    Join Date
    Jan 2011
    Posts
    42
    Thanks
    8
    Qt products
    Qt4 Qt/Embedded

    Default Re: Why the images from the HTML file is not loaded??

    Assume that i have save a webpage from this link http://doc.qt.nokia.com/4.7/classes.html. I have saved this webpage in my system and trying to insert it .

  9. #8
    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: Why the images from the HTML file is not loaded??

    Look, a QTextEdit is not intended to display whole webpages. Use webkit for it. If you still want to use the text edit, you have to embed all images into the resource or adjust the file paths. You then also have to go through the css files! But that is really pain in the a***

  10. The following user says thank you to Lykurg for this useful post:

    rleojoseph (1st March 2011)

  11. #9
    Join Date
    Mar 2011
    Location
    Denmark
    Posts
    74
    Thanks
    7
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Why the images from the HTML file is not loaded??

    Lykurg about your wiki article, I use a similar system for displaying images in a QTextBrowser, we have a system where I make a request to the database/server (depending whether we are offline or online) to get the html and then I intercept the QTextBrowser::loadResource calls to load any images/audiofiles from the appropriate datasource, then I call qtextdocument.add resource like in your article.

    My question is can i trust the QTextBrowser's resource cache to limit itself to a respectable size or should I worry about unloading the resources manually? ( I don't know much about how it's resource cache works )

Similar Threads

  1. How to use html to show overlapped images in QToolTip
    By LorenLiu in forum Qt Programming
    Replies: 0
    Last Post: 19th April 2010, 08:52
  2. QTextEdit HTML Processing of Base64 Images
    By millsks in forum Qt Programming
    Replies: 0
    Last Post: 24th November 2009, 15:02
  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. getting images out of html
    By hijinks in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2006, 23:17

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.