Here is an example of how I add instances of a class to my QScriptEngine:
void Window::runCurrentScript(QRect rect)
{
Rectangle *script_mouse = new Rectangle(rect.normalized());
QScriptEngine engine;
QScriptValue o2 = engine.newQObject(script_mouse);
engine.globalObject().setProperty("mouse", o2);
p_current_script = editor->toPlainText();
// Run the currently selected script...
QScriptValue result = engine.evaluate(p_current_script);
canvas->repaint();
}
All of this works fine but I would like to be able to create new Rectangles in my scripts like so:
var rect = new Rectangle();
How do I do that?