Hi,

I used a QTextBrowser in order to show simple http page loaded from my website. This page contains several images.

In order to get them loaded in the QTextBrowser, I subclassed it and reimplement loadResource function as this :

Qt Code:
  1. QVariant TextBrowserExt::loadResource ( int type, const QUrl & name )
  2. {
  3.  
  4. if(type==QTextDocument::ImageResource ){
  5.  
  6. QHttp picturl(name.host(),80);
  7.  
  8. connect(&picturl, SIGNAL(done(bool)), this, SLOT(finClientHttp(bool)));
  9. QHttpRequestHeader header("GET", name.path());
  10. header.setValue("Host", name.host());
  11. QByteArray searchstring;
  12. QBuffer *response;
  13. response = new QBuffer();
  14. endRequest = false;
  15. errorRequest = false;
  16. timeout = false;
  17.  
  18.  
  19. if (picturl.request(header, searchstring, response)) {
  20. timer.start(10000, this);
  21. while (!endRequest) {
  22. QCoreApplication::processEvents();
  23. }
  24. timer.stop();
  25. if (!timeout) {
  26. if (!errorRequest) {
  27. if (picturl.lastResponse().statusCode() == 200) {
  28.  
  29.  
  30. return response->data();
  31. }
  32.  
  33. }
  34. }
  35. }
  36. }
  37.  
  38. }
To copy to clipboard, switch view to plain text mode 

This implementation is maybie not the best but it works great and I can see all the images in the QtextBrowser.

The problem is that the size of the images is not good. They all appears to be 30% more than they should do. For try, I saved the downloaded images in files and the have the good size.

I don't understand why the QTextBrowser wants to resize this pictures.

This is the content of my QtextBrowser:
Qt Code:
  1. <html><body><img src="http://www.mywebsite.com/myimage.jpg"></html></body>
To copy to clipboard, switch view to plain text mode 

Does somebody experience something similar to dis ?