Qt4: Jak wywołać funkcje JavaScript na stronie z C ++ przez QtWebkit?

Próbuję napisać prostą przeglądarkę dzienników za pomocą portu / implementacji QT4 WebKit. Mój kod HTML wygląda tak:

http://pastie.org/613296

Dokładniej, próbuję dowiedzieć się, jak wywołać funkcję add_message (), która jest zdefiniowana w<script> sekcja w dokumencie HTML z mojego kodu C ++.

// 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");

questionAnswers(1)

yourAnswerToTheQuestion