0
QObject::connect(webview->page()->mainFrame(), SIGNAL(initialLayoutCompleted()), webview->page()->mainFrame(), SLOT(evaluateJavaScript("alert(); null")));

My code can be compiled but then happens nothing. evaluateJavascript is not the problem, because I have tested in standalone and it works fine. The signal is neither the problem, because I have done:

QObject::connect(webview->page()->mainFrame(), SIGNAL(initialLayoutCompleted()), webview, SLOT(close())));

And the app is closed properly. I think that the problem is related with the "webview->page->mainFrame()" part.

Thanks.

4

1 回答 1

0

evaluateJavaScript("alert(); null") is not the name of a slot, it's a fully formed function call. The QObject:connect() fails because it expects the name of a slot, including the argument types, not a function call.

You need to provide your own slot function here, inside a class of yours, possibly inheriting QWebView. Then put that evaluateJavascript("...") call inside that slot and connect SIGNAL(initialLayoutCompleted()) to it.

于 2013-03-30T00:59:48.657 回答