【发布时间】:2010-11-27 10:16:10
【问题描述】:
我正在尝试使用 Qt4 的 WebKit 端口/实现编写一个简单的日志查看器。我的 HTML 代码如下所示:
更具体地说,我试图找出如何从我的 C++ 代码中调用 HTML 文档的 <script> 部分中定义的 add_message() 函数。
// Doesn't work:
QWebElement targetElement = chatView->page()->mainFrame()->findFirstElement("head").firstChild("script");
// Function is not included, either...
qDebug() << targetElement.tagName() << targetElement.functions();
// The ultimate attempt in calling the function anyway:
QVariant functionResult = targetElement.callFunction("add_message");
【问题讨论】:
标签: javascript qt4 webkit call qtwebkit