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
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
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
Can someone solve this problem? I have the same problem...
If I load the html code with Firefox, for example, the images appears to be ok.
Hi,
How are you describing the image path in html files? Is it relative? You need to use the full path somewhere, either directly in html files or full path to html files in your application.
Regards,
Manoj
diogolr (27th July 2008)
Thanks Manoj...
The following code works for me :
Qt Code:
QDir dir; img_path = img_path.arg( path ).arg( "imgs/image_name.png" );To copy to clipboard, switch view to plain text mode
Last edited by diogolr; 27th July 2008 at 04:54.
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.
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