I am trying to get Qt WebView to display an html file that is embedded in the Qt resource, but I cannot get it to work. I have created a new application Qt Quick and added a simple qml file:
import QtQuick 2.0 import QtWebKit 3.0 Rectangle { id: content width: 800 height: 600 color: "black" WebView { id: webView anchors.fill: parent url: "qrc:/res/test.html" } }
Then I created (using the constructor) resource file that looks like this:
<RCC> <qresource prefix="/res"> <file>test.html</file> </qresource> </RCC> > <RCC> <qresource prefix="/res"> <file>test.html</file> </qresource> </RCC>
and I created a simple file test.html (in the same directory as the file .qrc):
<html> <head><title>Hello</title></head> <body> <h1>Hello World!</h1> </body> </html> h1> <html> <head><title>Hello</title></head> <body> <h1>Hello World!</h1> </body> </html>
Result - just a blank white window. If I use a normal url No ( http://www.stackoverflow.com ) in qml file as a URL-addresses, it works - page is displayed. If I use the name of an embedded image ( qrc:/qt-project.org/mac/cursors/images/pluscursor.png ), the image will appear.
I think that really added html file (it is, at least, is listed when I list the embedded assets), but my understanding of the Qt Resource System is limited, so I could well misunderstand something fundamental.
Can you tell me someone that I'm doing wrong?
Update: I have verified that the behavior is the same, if I try to tell the web browser to download the URL-address of a C ++. I also checked that the resource is actually built - I can open and read resource using QResource. In addition, it does not seem to Qt5: http://qt-project.org/forums/viewthread/18181 (someone with a similar problem with Qt 4.8).
source share