Hey All,

I have hit a little snag, and haven't been able to find exactly what I am looking for. I want to be able to grab html elements out of a webframe, manipulate them with QtScript, and put them back in. Maybe there is some way already to do this, but what I have found so far is that I have to register a metattype for QWebElement, which means creating a template to convert the QWebElement to a QScriptValue and back again.

The problem is, I am a bit away for knowing how to do this. I checked out the example code, but not sure I really follow it. I don't want just values, I want a calleable/malleable class that when I do something to it in qtscript, it reflects in the page. Am I reinventing the wheel? Aiming too high?

Here is the function that returns the QWebElement;

QWebElement MyWindow::getElementById(QString id) {
QWebElement e =_self->webView->page()->currentFrame()->findFirstElement(id);
return e;
}

in QtScript, I would like to be able to do this:

Qt Code:
  1. var elem = this.getElementById('#test'); // works, but throws the qRegisterMetaType error
  2. elem.setInnerXml("<span class='someclass'>Yay, I worked!</span>");
To copy to clipboard, switch view to plain text mode 

I can imagine some ways to dance around this, like creating a slot called setHtmlOfElement(QString id, QString html) { ... }

If there is no simple way to wrap the QWebElement up for QTScript, I may just do that.

I am just wondering, is there a better way?

Thanks in advance for any help and pointers,
Jason