In QT 4.6 w / Webkit: how to handle popup requests (WebView :: createWindow)?

I am new to QT and am trying to create a test browser. Now I am trying to handle js based popup requests. After reading the QT documentation, I found out that I need to reimplement the QWebView :: createWindow method in order to do this.

Now I have re-executed this method, but it doesn't seem to be called when I try to click the link that triggers the popup.

Can anyone help me? Do you need to subclass the WebView and WebPage classes? If so, how do I do it? I am completely new to QT and I did a lot of searching and found nothing.

Thanks everyone for any tips and advice!

+2


a source to share


2 answers


Did you forget to set the following parameters?

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

      



And don't forget to call the parent class's createWindow () method. There is a note in the documentation:

Note. If the createWindow () method of the associated page is overridden, that method is not called unless explicitly done in Override.

+4


a source


Ignore my second question (in the comments area), here's what I did to grab a new window request (thanks a lot to Duncan's tip!):

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

      



This was used during the initialization of the custom WebView class.

Hope this might be helpful to someone. Thanks!

0


a source







All Articles