Guest User

Untitled

a guest
Aug 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. // a) konverze na QObject
  2. this->supernova = new QScriptEngine(dynamic_cast<QObject*> (this));
  3.  
  4. printf("%p->%p", this, this->supernova->parent());
  5. qDebug() << this << this->supernova->parent(); // NsProcess(0x82eb9b8) NsProcess(0x82eb9b8)
  6.  
  7. // b) předání
  8. QScriptValue constructorFile(QScriptContext *context, QScriptEngine *engine)
  9. {
  10. QObject *object = new API::File(engine->parent(), context);
  11. return engine->newQObject(object, QScriptEngine::ScriptOwnership);
  12. }
  13.  
  14. // c) konverze na NsProcess
  15. File::File(QObject *engine, QScriptContext *args) : QObject()
  16. {
  17. this->ps = dynamic_cast<NsProcess*> (engine->parent());
  18. printf("%p->%p", engine->parent(), this->ps);
  19. qDebug() << engine->parent() << this->ps; // QObject(0x0) QObject(0x0)
  20. }
  21.  
  22. // crash
  23. QString File::doSomething()
  24. {
  25. this->ps->IO->writeLine("The method File::doSomething() has been called.");
  26. return "I'm doing something cooler than you are!";
  27. }
Add Comment
Please, Sign In to add comment