[Kde-bindings] Re: Custom properties on QObjects defined in qtruby

Sven Moritz Hallberg hallberg at pre-sense.de
Thu Apr 7 19:16:38 UTC 2011

On 02/10/2011 09:19 PM, Arno Rehn wrote:
> On Thursday 10 February 2011 20:44:25 Sven Moritz Hallberg wrote:
>>     class Foo < Qt::Object
>>       slots ...
>>       signals ...
>>       properties ...
>>       ...
>>     end
>> AFAICS this would allow property binding on the QML side because of notify
>> signals, right?
>> I've looked around the qtruby source and found relevant code in
>> qtruby/src/lib/Qt/qtruby4.rb: Base::slots, Base::signals, MetaInfo,
>> Internal::makeMetaData, ...
>> Some docs on the qt_meta_data and qt_meta_stringdata structures here:
>>     http://dev.libqxt.org/libqxt/wiki/Meta_Object_Format
>> also the relevant functions in qt/src/tools/moc/generator.cpp.
>> Further info/pointers would be appreciated! :)
> There are no plans so far, but we want to get QtRuby development up to speed 
> again. Patches welcome. It's not hard to do, Qyoto for example already has 
> support for properties.

Hi again,

I've tried my hand at implementing property support for qtruby, however so far
it's not working correctly. I've augmented the metadata generation in
qtruby4.rb to include the properties and that seems to work. I can see my
so-defined properties show up on the QML side, but when I query them, I always
get QVariants with isNull==true.

As far as I can tell, I need to catch a

    qt_metacall(ReadProperty, ...)

somewhere and let it dispatch to the given READ function. Is that right? I
just can't see where or how.

I've attached a test program to demonstrate. Thanks to Ruby's ability to
reopen classes and override methods, it includes all the modifications I made
to qtruby directly. It instanciates a QObject-derived class on the Ruby side
that declares a property and passes it to a QML frontend which queries all
properties on the object. Press the button and it will try to set the test

Thanks in advance!

Sven Moritz Hallberg                      hallberg at pre-sense.de
                                   Tel. +49 - 40 / 244 24 07-28
                                   Fax  +49 - 40 / 244 24 07-24
PRESENSE Technologies GmbH            Sachsenstr. 5, D-20097 HH
                                         USt-IdNr.: DE263765024
Geschäftsführer/Managing Directors       AG Hamburg, HRB 107844
Till Dörges           Jürgen Sander              Axel Theilmann
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt2.rb
Type: application/x-ruby
Size: 11337 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20110407/2aa04a6a/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: qt2.qml
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20110407/2aa04a6a/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20110407/2aa04a6a/attachment.sig>

More information about the Kde-bindings mailing list