QtScript emit signal and "parent" class catch it
-
Hi,
Is it possible to emit a signal into a QtScript and catch it in the parent class (the class in which the engine was created)?
If so how can i do that?i tried this:
@QScriptValue that = engine->newQObject(this, QScriptEngine::QtOwnership, QScriptEngine::ExcludeChildObjects | QScriptEngine::ExcludeSuperClassMethods | QScriptEngine::ExcludeSuperClassProperties);
engine->globalObject().setProperty("document",that);
engine->evaluate("document.SendMessageFromScript(123);");
@where SendMessageFromScript is the parent function but seems not to work...
thanks,
Riccardo -
Hi,
I modified like this:
@QScriptValue that = engine->newQObject(this, QScriptEngine::QtOwnership, QScriptEngine::ExcludeChildObjects | QScriptEngine::ExcludeSuperClassMethods | QScriptEngine::ExcludeSuperClassProperties);
engine->globalObject().setProperty("test",that);
connect(this,SIGNAL(SendMessageFromScript(QString)),this,SLOT(SendMessageFromScriptSlot(QString)));
engine->evaluate("test.SendMessageFromScript(123)");
@where SendMessageFromScript is the signal connected to a parent function and it seems to work
Is the correct way?