I've problem with open local html file in QWebView widget. So, I do it like this:
QWebView *myWebView = new QWebView;
myWebView->load(QUrl("qrc:/index.htm"));
Sure, I have added index.htm in resources. But in QWebView there is white screen. I tried to open local file with Firefox, it's allright.
What should I do to fix it?
PS: htm-page uses js and css files, but I've also added them to resources too. PSS: Also, I tried to do it such way:
QFile res(":/index.htm");
res.open(QIODevice::ReadOnly|QIODevice::Text);
myWebView->setHtml(res.readAll());
but it doesn't help.
Have you tried just loading the file to QByteArray to verify it loads correctly?
Edit:
Something like (untested, but you get the idea):
QFile file(":/index.htm");
if(file.open(QIODevice::ReadOnly)) {
QByteArray dump = file.readAll();
qDebug() << "contents: " << dump;
} else {
qDebug() << "error: " << file.error();
}
The error()
method returns QFile::FileError
enum.