質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top