[Qt-qml] Exporting overloaded methods to QML
Kent Hansen
kent.hansen at nokia.com
Fri Jun 18 16:04:31 CEST 2010
On 18. juni 2010 14:43, ext Artur Souza (MoRpHeUz) wrote:
> On Fri, Jun 18, 2010 at 6:10 AM, Kent Hansen<kent.hansen at nokia.com> wrote:
>
>
>> I _think_ you should be able to get the engine by creating a C++ slot
>> that takes a QScriptValue as argument, call that slot from QML, and call
>> QScriptValue::engine() on the argument. If thats works, it effectively
>> means we do already expose the QtScript API in public, but not with the
>> intention to use the full API (e.g., it should be fine to call
>> toNumber() on the QScriptValue, but not, say, installing a custom
>> QScriptEngineAgent on the engine()).
>>
> I will try this and let you know about the results!
>
I verified that this does indeed work.
>
>> Hmm, taking this idea further, did you try subclassing QScriptable? Then
>> you could get at the arguments and thisObject() too. :-)
>>
> Seems like a good idea too ;)
>
This doesn't work. QtDeclarative currently doesn't use the same QObject
method call logic as QtScript. You can "fix" that by uncommenting the
two lines after "// Uncomment to use QtScript method call logic" in
qdeclarativeobjectscriptclass.cpp. That will also make overload
resolution work.
Kent
More information about the Qt-qml
mailing list