J-P Nurmi
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">
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:
and launch the app in C:/HTMLViewer/Qt Code:
viewer->setHtml("html/index.html");To copy to clipboard, switch view to plain text mode
versus when you doC:/HTMLViewer/> app.exe
and launch the app in C:/HTMLViewer/htmlQt Code:
viewer->setHtml("index.html");To copy to clipboard, switch view to plain text mode
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.C:/HTMLViewer/html> ..\app.exe
J-P Nurmi
kerchen (6th May 2009)
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.
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.
What about <img src="file:///html/img1.jpg">?
J-P Nurmi
we have to provide the whole absolute file path along with file protocol i.e.
file:///c:/HTMLViewer/html/img1.jpg
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?
Coud u please post a chunk of your code loading a web-page and a chunk of html code.
1) make an index.html
<html><body><img src="img.png"></body></html>
2) put index.html and img.png into the same directory.
3) try to load the index.html
Manok
I had the same issues with my QWebView setHtml function.
It did load the html file but not the .png image that is located inside the subfolder /images under the current application directory:
<img style="border: 1px solid" alt="berlin" src="./images/berlin.png">
On my Unix box the current directory in src attribute above is shown as a dot "." not as a column ":"
Inside my Qt application that is using QWebView to see the html file I have this call to load the HTML in this way.
1. In order to load this image I had to create a new resource file qwebview.qrc
and put this file in the same folder as my application files.
In this qwebview.qrc file I reference my image file with the same realtive path specified above
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>images/berlin.png</file>
</qresource>
</RCC>
2. I add the resource qwebview.qrc file into the .pro file if my application under RESOURCES key as below:
CONFIG += qt debug
QT += webkit
SOURCES += main.cpp
RESOURCES += qwebview.qrc
3. I used my QWebView object and call setHTML with a QUrl that is pointing to qrc resource file find in the current directory as below.
MyWebView->setHtml(file.readAll(), QUrl("qrc:/"));
4. I got the images/berlin.png image file loaded in my HTML page but is true that having a qrc (RESOURCE file) inside my project would compile the .png file inside the application binary executable preserving the same original relative path as described in the < src attribute > and in the .qrc file. Maybe this tight connection from the compilation stage till the end make this woring.
5. I asked QT support people about addResource option to add an external file image inside the QWebView when an HTML file is loaded and they told me that the only way now to do it in Qt 4.5.0 is:
<<The only way to be able handle what is not handled by QWebPage is to utilize the unsupportedContent() signal, this is emitted when it is unable to handle a link that the user is trying to have loaded. Here you can place what you wanted in that frame. If you look at the browser demo then you can see this in operation in the webview.cpp file. Look at the WebPage::handleUnsupportedContent() function to see how to do this>>
I looked into that code is quite spooky.
Can you please tell me how to reach them to get the answer for this?
You could try the qt4-preview-feedback list.
http://trolltech.com/company/newsroo...-17.6192777923
Hi, you must use the absolute path for the image in the html code:
I solved that, including html file loading at this way:
The arg %1 in the src parameter is the key.Qt Code:
<img style="width: 300px; height: 84px;" alt="Image" src="%1" align="left">To copy to clipboard, switch view to plain text mode
Qt Code:
trUtf8("Can't Open '%1'").arg(fileName)); } else { // First, load the content file to a stream QString htmlString; // download all contents to a QString htmlString = stream.readAll(); // re-download the html contents but, modifiying the parameter %1. WebView->setHtml(htmlWebView); // finally you could use qDebug to show the result of the code qDebug() << htmlWebView; }To copy to clipboard, switch view to plain text mode
Bookmarks