Page 1 of 2 12 LastLast
Results 1 to 20 of 28

Thread: QWebview not showing images

  1. #1
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default QWebview not showing images

    Hi!

    I am trying QT 4.4 tecnology preview for webkit to have full html functionality in my application. It does not display images!! Any help why?

    Regards,
    Manoj

  2. #2
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QWebview not showing images

    I'm sorry that I don't have an answer for you, but maybe it doesn't work, because it still is a technology preview ?

  3. #3
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    but why is it so that it shows the images in online page but not offline? i.e. If I show the page "http://www.yahoo.com" it shows perfectly but if I save the same page in html format along with its all images, it shows everything except images???

    I am stuck here with this!! please help!!

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWebview not showing images

    How do the links look like? What is current working directory?
    J-P Nurmi

  5. #5
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    Current working directory is the directory where I am executing my project from! There are very funny things happening:
    (1) It shows the online page perfectly.
    (2) It does not show the offline images.
    (3) It shows the images from some server in offline pages but that too only when I load the page with setHtml() function, not with load() function!!

    How do I get it done??

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWebview not showing images

    Could you answer the questions, please?
    • What does
      Qt Code:
      1. qDebug() << QDir::currentPath();
      To copy to clipboard, switch view to plain text mode 
      output?
    • In saved HTML page, what do missing images have as img-elements src attribute?
      <img src="..."/>
    J-P Nurmi

  7. #7
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    Hi!

    The current Path returns:
    C:/HTMLViewer

    The image source is:
    "img1.jpg"

    I am passing html/test.htm as path for url and img1.jpg is stored in html folder.

    BTW: Image is displayed if I give the src as: ftp::///C:/HTMLViewer/html/img1.jpg but I don't want to specify absolute paths here.

  8. #8
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QWebview not showing images

    Did you compile Qt with .jpg support?
    Qt 5.3 Opensource & Creator 3.1.2

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWebview not showing images

    So it was about current working directory after all. src="image.png" means that the image is searched from the current directory. I don't know if there is a possibility to set search paths or something, but presumably the images are shown once you launch the application from C:\HTMLViewer\html or you change it to src="html/image.png".
    J-P Nurmi

  10. #10
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    Quote Originally Posted by MarkoSan View Post
    Did you compile Qt with .jpg support?
    I compiled QT with GIF support and I think that it is always compiled with jpg and mng support by default. I also told you that it is displaying images if I give the online location of images or the full absolute location with FTP.

  11. #11
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    Quote Originally Posted by jpn View Post
    So it was about current working directory after all. src="image.png" means that the image is searched from the current directory. I don't know if there is a possibility to set search paths or something, but presumably the images are shown once you launch the application from C:\HTMLViewer\html or you change it to src="html/image.png".
    No, it does not work that way even.

  12. #12
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWebview not showing images

    Quote Originally Posted by manojmka View Post
    No, it does not work that way even.
    So, exactly what did you try? It might prove to be useful to be as detailed as possible. "My car does not work" is not very useful information to a car mechanic. Does it print any warnings to debug output (provided that you have QT += console)?
    J-P Nurmi

  13. #13
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    Well, I think I tried to write in detail but may be you can tell me what details are you expecting?

    I have already stated that:
    (1) It shows the online page perfectly.
    (2) It does not show the offline images.
    (3) It shows the images from some server in offline pages but that too only when I load the page with setHtml() function, not with load() function!!
    (4) It also show the images from disk if I give them as: <img src=FTP:///C:/HTMLViewer/html/img1.jpg">

  14. #14
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWebview not showing images

    Start with enabling console so you can see the debug output, which might provide useful information.

    Notice, that there is a significant difference when index.html contains src="image.png" and you do:
    Qt Code:
    1. viewer->setHtml("html/index.html");
    To copy to clipboard, switch view to plain text mode 
    and launch the app in C:/HTMLViewer/
    C:/HTMLViewer/> app.exe
    versus when you do
    Qt Code:
    1. viewer->setHtml("index.html");
    To copy to clipboard, switch view to plain text mode 
    and launch the app in C:/HTMLViewer/html
    C:/HTMLViewer/html> ..\app.exe
    Now that I take a look at QWebView docs, it seems that setHtml() takes an optional baseUrl parameter. Did you pass anything as baseUrl? All the relative paths are clearly relative to this baseUrl.
    J-P Nurmi

  15. The following user says thank you to jpn for this useful post:

    kerchen (6th May 2009)

  16. #15
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    Hi!

    Thank you for telling me the benifits of console view. I started the same but did not get any information regarding paths in html file in fact, I did not get any information on the console view on loading the page itself.

    I tried running the application both the ways, you describe but no luck.

    I also tried to add the baseURL in setHtml function and that also did not produce any results. BTW, baseURL is only available in setHtml() function and that is not usable if I want to load a html page from some url. I will have to use load() method for this purpose.

  17. #16
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    I beg the help of some trolltech guys here. I am really stuck at this!! I don't believe that a tool like webkit is not able to show up images from local disk.

  18. #17
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWebview not showing images

    What about <img src="file:///html/img1.jpg">?
    J-P Nurmi

  19. #18
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    we have to provide the whole absolute file path along with file protocol i.e.
    file:///c:/HTMLViewer/html/img1.jpg

  20. #19
    Join Date
    May 2007
    Posts
    106
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QWebview not showing images

    I am eagerly waiting for some of trolltech guys to answer this! Am I making some mistake here or it is a bug to be fixed?? Can I rely on the final release and wait for the same?

  21. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebview not showing images

    Quote Originally Posted by manojmka View Post
    I am eagerly waiting for some of trolltech guys to answer this!
    It's hard to find Trolltech employees here.

Similar Threads

  1. about qt/embedded widgets showing in ARM platform
    By xianshuiren in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 3rd December 2007, 05:48
  2. Problem showing raw images
    By wkit23 in forum Qt Programming
    Replies: 5
    Last Post: 8th September 2006, 13:33

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.