Quantcast
Channel: Qt DevNet forums: Qt WebKit
Viewing all articles
Browse latest Browse all 542

Mixing qrc and file schemes in a webkit app

$
0
0
Hi guys! What I want to accomplish is quite simple; but first of all here is the source for my project so you have an idea. My main cpp file: #include <QApplication> #include <QWebView> int main(int argc, char **argv) {  QApplication app(argc, argv);  QWebView *view = new QWebView();  view->setContextMenuPolicy(Qt::PreventContextMenu);  view->settings()->setAttribute(QWebSettings::PluginsEnabled, true);  view->settings()->setAttribute(QWebSettings::XSSAuditingEnabled,0);  view->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls,1);  view->load(QUrl("qrc:///html/index.html"));  view->showFullScreen();  return app.exec(); } My resource file: <RCC>  <qresource prefix="/">   <file>html/index.html</file>   <file>html/style.css</file>   <file>html/script.js</file>  </qresource> </RCC> My index.html file: <!DOCTYPE html> <html lang="en"> <head>  <meta charset="UTF-8">  <title>Hello World!</title>  <link type="text/css" rel="stylesheet" href="style.css" /> </head> <body>  <p><h1>Hello World!</h1></p> <video width="320" height="240" controls> <source src="myvideo.mp4" type="video/mp4"> </video>  [removed][removed] </body> </html> What I want is to be able to embed index.html, style.css and script.js files in my resource file and load myvideo.mp4 file from local file. Relative path here will assume I’m still using qrc scheme and I can not use absolute path with file scheme because I don’t know where my app’s path is. I know I can use webkit’s bridge [qt-project.org] but how to achieve that? Is there any other way to do that to? Thank you.

Viewing all articles
Browse latest Browse all 542

Trending Articles