PDA

View Full Version : webview createWindow for javascrip applet



wambagilles
21st March 2011, 15:16
hi i reimpleted the createWindow method of qwebview to add support for javascript applet for my web browser, i also enble the setting javacanopenwindows, this is what i did

QWebView * WebView::createWindow ( QWebPage::WebWindowType type ){

QWidget *view = new QWidget;
QWebView *appletview = new QWebView(view);
appletview = QWebView::createWindow (type );
//appletview->load(appletview->url());

view->show();

}

but whenever a page open a javascript applet, i get two windows that get open, and non of them loads the intended content, please help!

everlynde
22nd March 2011, 17:06
They are several errors in the procedure above,

You create two webviews... First in a widget and second by calling parent createWindow(). Use only one of this constructor and "return" the pointer ...



QWebView * WebView::createWindow ( QWebPage::WebWindowType type ) {
QWebView *appletview = new QWebView(NULL);
// ...
return appletView;
}


Instead of made a show() call in the createWindow function, try to do it on the loadFinished() signal. This reduce flickering of your page when the window open and draw the content of the page...


WebView::WebView(QWidget * parent)
:QWebView(parent)
{
hide();
...
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(onPageLoadFinished(bool)));
}

void WebView::onPageLoadFinished(bool value)
{
show();
}

wambagilles
23rd March 2011, 00:00
many thanks, it works, thanks alot!!!