tags:

views:

398

answers:

2

Hi all,

I'm new to QT and have been trying to create a test browser. What I'm trying to do now is to handle js-based popup requests. After reading the QT documentation, I learned that I need to re-implement the QWebView::createWindow method to do just that.

Now I've re-implemented this method, but it seems to be not called when I try to click a link that triggers a popup window.

Can any one help me? Do I need to subclass both the WebView and WebPage classes? If so, how do I do that? I'm quite new to QT and I've done tons of searches and found nothing.

Thank you all in advance for any hint and advice!

+1  A: 

Did you remember to set the following options?

view->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
view->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);

And don't forget to call the parent class createWindow() method. The documentation has a note on that:

Note: If the createWindow() method of the associated page is reimplemented, this method is not called, unless explicitly done so in the reimplementation.

duncan
@duncan,Many thanks for your help!I'm pretty sure the JavaScript is enabled, since all other js calls are working perfectly fine.I tried to use the setAttribute call to enable to JavascriptCanOpenWindows, however I encounter this error message:no matching function for call to QWidget::setAttribute...I was using this code:myWebView->page()->view()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);Is this incorrect?I believe this is an extremely noob question, and thanks again for any insight!
CM
A: 

Nevermind my second question (in the comment area), here's what I did to capture the new window request (many thanks to Duncan's hint!):

page()->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);

This was used inside the initiation process of the custom WebView class.

Hope this can be useful to someone. Thanks!

CM

related questions