2

I need access to functions that wasn't marked as Q_INVOKABLE nor Q_SLOTS. Qt script module has mechanism called defaultPrototype. I wonder if it possible in QML?

I saw QtDevDays presentatin QtDD12 - QtQuick under the hood - Thomas McGuire and at 18 minute Thomas shows pure QML widget application. I think you cannot achieve it without exporting/exposing some non-invokable functions to script environment.

Is there any mechanism in QML like defualtPrototype in QtScript?

Nightmare
  • 63
  • 1
  • 7

1 Answers1

2

QML uses Qt Script under hood, so using the default prototype mechanism is perfectly possible. Only problem is obtaining the script engine of a declarative engine as their is no obvious API for that. Have look at the code in libkdeclarative, especially KDeclarative::initialize(), for a viable hack to do so.

sebasgo
  • 3,845
  • 23
  • 28
  • 1
    Actually it works partially. Prototype doesn't work for objects instantiated by QmlEngine, but works for objects instantiated in JavaScript. – Nightmare Jan 03 '13 at 14:57