[Kde-bindings] Re: Custom properties on QObjects defined in qtruby
Richard Dale
richard.dale at telefonica.net
Thu May 19 14:59:56 UTC 2011
On Thursday, April 14, 2011 08:55:24 PM Sven Moritz Hallberg wrote:
> On 04/13/2011 08:17 PM, Sven Moritz Hallberg wrote:
> > [ruby] qt_readprop(0 "stuff") -> "ho" # ReadProperty called
> > and... [ruby] qt_readprop(0 "stuff") -> "ho" # ...returning
> > correct value [qml] stuff: # still,
> > empty!?
> >
> > maybe you have an idea which piece is missing... otherwise i'll do some
> > more investigating...
>
> got it, i remembered that QML wants all properties to be of QVariant type.
> duh! now, declaring
>
> properties 'QVariant stuff READ getStuff WRITE changeStuff NOTIFY
> stuffChanged'
>
> works as intended!
>
>
> because the READ/WRITE/NOTIFY stuff looks pretty generic, i'm thinking
> about adding a simple variant
>
> properties :stuff
>
> that would define suitable READ/WRITE methods and a NOTIFY signal. do you
> think that would be a good idea or should it be a seperate function?
That sounds like a good idea to me.
I was thinking of overloading 'attr_accessor' in Qt::Object derived classes so
that they would define Qt properties. Maybe having another method called
'properties' is clearer. I think we need another form that has the C++ type
signature for when the values aren't Qt::Variants though, and I don't think
changing 'attr_accessor' to take a list of strings would look very nice. It is
better to allow a 'properties' to take either a list of symbols or strings
like the QtRuby 'slots' and 'signals' methods do.
-- Richard
More information about the Kde-bindings
mailing list