I was having this issue as well. A related thread addresses it perfectly. You just need to tweak the context a bit before you call evaluate:

Qt Code:
  1. QScriptContext *context = engine->currentContext();
  2. QScriptContext *parent=context->parentContext();
  3.  
  4. if(parent!=0)
  5. {
  6. context->setActivationObject(context->parentContext()->activationObject());
  7. context->setThisObject(context->parentContext()->thisObject());
  8. }
To copy to clipboard, switch view to plain text mode 

Original thread: http://www.qtcentre.org/threads/2043...pt-from-script