Hi, you must use the absolute path for the image in the html code:
I solved that, including html file loading at this way:
<img style="width: 300px; height: 84px;" alt="Image" src="%1" align="left">
<img style="width: 300px; height: 84px;" alt="Image" src="%1" align="left">
To copy to clipboard, switch view to plain text mode
The arg %1 in the src parameter is the key.
QString fileName
= QDir::currentPath() + "/webs/page.html";
QMessageBox::warning(this, trUtf8
("Error Opening File"),
trUtf8("Can't Open '%1'").arg(fileName));
} else {
// First, load the content file to a stream
// download all contents to a QString
htmlString = stream.readAll();
// re-download the html contents but, modifiying the parameter %1.
QString htmlWebView
= htmlString.
arg("file://" + QDir::currentPath() + "/webs/image.png");
WebView->setHtml(htmlWebView);
// finally you could use qDebug to show the result of the code
qDebug() << htmlWebView;
}
QString fileName = QDir::currentPath() + "/webs/page.html";
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::warning(this, trUtf8("Error Opening File"),
trUtf8("Can't Open '%1'").arg(fileName));
} else {
// First, load the content file to a stream
QTextStream stream(&file);
QString htmlString;
// download all contents to a QString
htmlString = stream.readAll();
// re-download the html contents but, modifiying the parameter %1.
QString htmlWebView = htmlString.arg("file://" + QDir::currentPath() + "/webs/image.png");
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