Bug 24157

Summary: Flash content not visible if QWebView is inside QGraphicsView
Product: WebKit Reporter: Lasse Holmstedt <lasse.holmstedt>
Component: Plug-insAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: girish, hausmann, jturcotte, tonikitoo, yael
Priority: P2 Keywords: Qt
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.5   
Bug Depends on: 20081, 31232    
Bug Blocks:    

Description Lasse Holmstedt 2009-02-25 05:00:18 PST
When loading Flash content in a QWebView which is added inside QGraphicsView, the Flash content is not visible at all. It works, however, because JavaScript calls to the Flash object get through to it. 

If QWebView is added under some other container, like QMainWindow, Flash works 
just fine and everything is displayed. JavaScript works too as expected. 

The build used to test the problem was 41149, but it occurs with the build currently shipping with Qt 4.5.0-tp1 as well.

On the Flash side, following steps are required:
* ExternalInterface.addCallback("funcnameForJs", asFuncName);

On JS side, the script has to first wait for the Flash to be 100% initialized. After that, the call 

document.getElementById(flashElementName).funcnameForJs() 

can be made. This will show that the Flash itself does, in fact, work, it's just not visible. There must be other, easier ways to do it too though.

This example does NOT work as expected, and shows the real issue:

MainWindow::MainWindow(QWidget *parent)
   : QMainWindow(parent), ui(new Ui::MainWindowClass), editorObj(this)
{
   ui->setupUi(this);

   QString projpath("/your/path/here");

   QGraphicsView* graphicsView = new QGraphicsView(this);

   QGraphicsScene* scenePtr = new QGraphicsScene(graphicsView);
   webview = new QWebView();
   graphicsView->setScene(scenePtr);

   scenePtr->addWidget(webview);
   graphicsView->resize(800, 800);
   graphicsView->move(300, 50);

   webview->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
   webview->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled,
true);
   webview->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
   webview->load(QUrl("file://" + projpath +
"/someFlashAndJSEnabledFile.html"));
   webview->resize(600, 400);
   webview->show();

   QWidget* centralWidgetPtr = &editorObj;

   this->setCentralWidget(centralWidgetPtr);
}

As for Qt, one can for example do this working setup in a class that inherits QMainWindow:

MainWindow::MainWindow(QWidget *parent)
   : QMainWindow(parent), ui(new Ui::MainWindowClass)
{
   ui->setupUi(this);

   QString projpath("/your/path/here");

   webview = new QWebView(this);
   webview->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
   webview->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled,
true);
   webview->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);

   webview->load(QUrl("file://" + projpath +
"/someFlashAndJSEnabledFile.html"));

   webview->resize(600, 400);
   webview->show();

}
Comment 1 Simon Hausmann 2009-10-06 04:55:17 PDT
What's missing for this to work in all cases is support for also redirecting the output of windowed plugins, for example using the composite and damage extensions on X11.
Comment 2 Girish Ramakrishnan 2009-12-14 07:54:34 PST
Should we close this bug? I think we support Flash in QGraphicsWebView now but not in QWebView. I don't think it's useful to support flash in QWebView. Comments?

As for QGraphicsWebView, see the following related bugs
Windows - 32059
Mac - Fixed by 31183 , 31794, 31979.
Linux - 20081, 32059

See also : http://blog.forwardbias.in/2009/12/flash-in-qgraphicsview.html.
Comment 3 Girish Ramakrishnan 2009-12-14 07:55:40 PST
(In reply to comment #2)
> Should we close this bug? I think we support Flash in QGraphicsWebView now but
> not in QWebView. I don't think it's useful to support flash in QWebView.
> Comments?
> 

Err. To clarify, I don't think its useful to support flash in a QWebView that is embedded in QGraphicsView using QGraphicsProxyWidget.
Comment 4 Jocelyn Turcotte 2010-03-08 06:02:15 PST
This is a valid issue however the usecase seems exotic.
The normal way to achieve this would be to use the QGraphicsWebView introduced in Qt 4.6.

Please reopen if this solution do not meet the need.