[Interest] Questions about QML

Harri Porten porten at froglogic.com
Wed Oct 1 08:10:00 CEST 2014


On Tue, 30 Sep 2014, Oleg Shparber wrote:

> 4. Is there a way to provide my own container type? Overloading [] with 
> Q_INVOKABLE does not work. I'd like to have a custom buffer type which I 
> can use as myBuffer[index].

[] is not a function in JavaScript. It's a property access. a[b] equates 
to a.b (leaving the type and possible values of 'b' aside).

With the regular QObject slot and property based approach you might not be 
able to model such a random index access. But how about you implement a 
thin wrapping layer in JavaScript? Through __defineGetter_ you should be 
able to forward property access attempts to a C++ slot internally.

Harri.



More information about the Interest mailing list