Qt4: Como chamar funções JavaScript em uma página do C ++ via QtWebkit?

Eu estou tentando escrever um visualizador de log simples usando a porta / implementação do WebKit do Qt4. Meu código HTML é assim:

http://pastie.org/613296

Mais especificamente, estou tentando descobrir como chamar a função add_message () que é definida no<script> seção no documento HTML do meu código 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