How to actually use QWebView::createWindow()
i a developing a web browser using qt and c++ and i want to know how to actually use the QWebView::createWindow()
i am have a class which is the subclass of QWebView the class is webview i always re implement virtual QWebView * QWebView::createWindow(WebPage::WebWindowType type)
i have seen arora source code it helped me a lot but that also does not helped me in this case.
this was my research and much more i have searched a lot on google and the qt-project forums and many places
Ok, yesterday, after scratching my head for two hours, I came up with this quick solution (read "quick", maybe not the best, just a quick solution).
In your createWindow implementation, inside your QWebView subclass:
QWebView *WebView::createWindow(QWebPage::WebWindowType type)
QWebView *webView = new QWebView; QWebPage *newWeb = new QWebPage(webView); webView->setAttribute(Qt::WA_DeleteOnClose, true); webView->setPage(newWeb); webView->show(); return webView;
With this, every time JS wants to open a new window, your app will create and show this new window.
Hope it helps.
thanks man it works can you tell me how it works :)
This method is called from the QWebPage itself, searching for a reimplementation on your QWebPage subclass, then, after looking without success, it goes upside to your QWebView reimplementation. Within it, the caller takes control of the object (a new QWebView in this case) and internally inits its QWebPage with the data taken from the web element that shot the event (in this case, the JS script).
You must take a look at the QtWebKit code at this point (as I should) to fully understand this process.
I'm glad to help!
thanks man i got it you have solved my big problem
It works for type browser window pages, but it doesn't seem to work for modal pages, e.g. asking for credentials.