Originally Posted by
probine
But the pages are displayed, and every time an image should appear, I see a symbol, but not the images.
This is what the debug prints:
QTextBrowser: Cannot open 'http://localhost/website/images/logo.png' for reading
QFSFileEngine:
pen: No file name specified
Why?
I would guess that you try to give QTextBrowser some html such as "<img src="XXX" />", right?
The problem in that case is that, QTextBrowser is no WebBrowser and does not know how to handle http.
One possible aproach that I can see (but have not tested) is to create a new class inherrited from QTextBrowser and overload the loadResource function in a way where you check for the names you are interested in and resolve them.
For example like this (again not tested)
QVariant MyBrowser
::loadResource(int type,
const QUrl &name
) {
//lookup the correct QImage from a cache
return QVariant::fromValue(correctImage
);
} else {
}
}
QVariant MyBrowser::loadResource(int type, const QUrl &name)
{
if (type == QTextDocument::ImageResource
&& name.scheme() == QLatin1String("mypics")) {
QImage correctImage;
//lookup the correct QImage from a cache
return QVariant::fromValue(correctImage);
} else {
return QTextBrowser::loadResource(type, name);
}
}
To copy to clipboard, switch view to plain text mode
Then you should be able to show images when you call
myTextBrowser.
append(QLatin1String("<img src=\"mypics://theCurrentPicture.png\" />"));
myTextBrowser.append(QLatin1String("<img src=\"mypics://theCurrentPicture.png\" />"));
To copy to clipboard, switch view to plain text mode
Disclaimer: Shot from the Hip, not tested...might be completely the wrong track
Bookmarks