Opening local flash(.swf) file in QtWebKit?
Hello,
In my application I have a QWebView where i load a flash (.swf) QUrl.
load(QUrl("http://www.tizag.com/pics/example.swf"));
This works very well.
But when I try to open a flash file locally stored (same file downloaded and stored on the harddrive) it fails. Nothing is displayed.
load(QUrl("file:///home/moblin/Downloads/example.swf"));
I have tried modifying setting which could affect this but with no success. Example of these setting are:
settings()->setAttribute(QWebSettings::LocalContentCanAccessR emoteUrls, true);
settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
settings()->setAttribute(QWebSettings::PluginsEnabled, true);
Have someone experienced this problem before or can give me hints where the fault may be?
Re: Opening local flash(.swf) file in QtWebKit?
Here is a snippet of code that works on windows and linux that I use for a QGraphicsWebView, where the filename is stored in FlashFile:
QFileInfo info(FlashFile);
QString path = info.absolutePath() + "/";
QString fname = FlashFile;
fname.remove(path);
QUrl baseUrl = QUrl::fromLocalFile(path);
#ifdef Q_OS_LINUX
QString wmode = "opaque";
#else
QString wmode = "transparent"; // works best for windows
#endif
QString html = QString("<html><body><embed src='%1' wmode='%2' width=%3 height=%4>"
"</embed></body></html>").arg(fname).arg(wmode).arg(w).arg(h);
setHtml(html, baseUrl);