I have two QWebView instances(webView1 and webView2), both of them have a same statement like this:

webView->page()->mainFrame()->addToJavaScriptWindowObject("JSCallable", parent);

which parent refers to a same instance that have public slots for JS to invoke(i.e. both webView1 and webView2 will call the same method of the same instance), and I do call this statement whenever the webView(webView1 and webView2) load a new URL;


Now the problem is: only one webView can call the method of parent successfully while the other cannot.

I wonder whether it is possible to binding two webView to one obj for the purpose that the JavaScript in different pages can call a same method of a QObject.

Any one would help? I will thank you in advance.


Qt 4.8.4 / VS2010 with Windows 7

有帮助吗?

解决方案

After trial of several times, i figured it out that it was Possible to do stuff above.

I think this problem should be closed.

EDIT:

As mentioned in the comment that i should post the answer, so just modify the answer:

Yes it is Possible to register two webView to one obj, you just do what you do when you have only one webView, I did it wrong somewhere in the first place and worked it out later.

(Post it in case someone else encounter the same situation)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top