Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtScript emit signal and "parent" class catch it

QtScript emit signal and "parent" class catch it

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 864 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rileo8
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rileo8
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved