[Kde-bindings] Re: Custom properties on QObjects defined in qtruby
Sven Moritz Hallberg
hallberg at pre-sense.de
Wed Apr 13 18:17:10 UTC 2011
On 04/12/2011 05:34 PM, Arno Rehn wrote:
> qt_readprop should already return a Qt::Variant. In C++, you now have to
> extract the pointer of the underlying QVariant and assign that to _o[0].
thanks, here's what i've got on the C++ side now:
...
else if (_c == QMetaObject::ReadProperty) {
VALUE variant = rb_funcall(self, rb_intern("qt_readprop"), 1, argv[1]);
smokeruby_object *smoke_variant = value_obj_info(variant);
_o[0] = smoke_variant->ptr;
}
else if (_c == QMetaObject::WriteProperty) {
smokeruby_object *smoke_variant = alloc_smokeruby_object(true,
qtcore_Smoke, qtcore_Smoke->idClass("QVariant").index, _o[0]);
VALUE variant = set_obj_info("Qt::Variant", smoke_variant);
rb_funcall(self, rb_intern("qt_writeprop"), 2, argv[1], variant);
}
this looks pretty good, reading and writing the property from the ruby side
with property and setProperty makes a roundtrip through qt_metacall and
returns the correct result. however, no such luck for QML so far... that still
shows an empty string, even though it *does* go through qt_metacall and
*setting* the property from QML works! the following is trace output i'm
generating to show what's going on:
[qtruby] we're in qt_metacall!! _c=1 # ReadProperty
[ruby] qt_readprop(0 "stuff") -> "ahoj" # ruby side fetching the value
[ruby] reading property -> "ahoj" # result: initial value
[qtruby] we're in qt_metacall!! _c=2 # WriteProperty
[ruby] qt_writeprop(0 "stuff", "hollo!") # ruby side setting the value
[ruby] Dings#changeStuff("hollo!") # setter method being called
[ruby] writing property -> true # result: success
[qtruby] we're in qt_metacall!! _c=1 # ReadProperty
[ruby] qt_readprop(0 "stuff") -> "hollo!" # ...
[ruby] reading property -> "hollo!" # result: changed value
[qml] dings properties: # enumerating properties...
[qml] foo: [object Object]
[qtruby] we're in qt_metacall!! _c=1 # objectName (twice?)
[qtruby] we're in qt_metacall!! _c=1
[qml] objectName:
[qml] changeStuff: [object Object] # slot
[qml] stuffChanged: [object Object] # signal
[qtruby] we're in qt_metacall!! _c=1 # ReadProperty
[ruby] qt_readprop(0 "stuff") -> "hollo!" # ruby side: as expected
[qtruby] we're in qt_metacall!! _c=1 # twice?
[ruby] qt_readprop(0 "stuff") -> "hollo!" # ...
[qml] stuff: # empty?!
then setting and enumerating again (some lines omitted):
[qml] calling changeStuff slot # dings.changeStuff("hey")
[qtruby] we're in qt_metacall!! _c=0 # InvokeMetaMethod
[ruby] Dings#changeStuff("hey") # setter on ruby side
[qml] assigning property # dings.stuff = "ho"
[qtruby] we're in qt_metacall!! _c=2 # WriteProperty
[ruby] qt_writeprop(0 "stuff", "ho")
[ruby] Dings#changeStuff("ho")
[qml] dings properties: # enumerating...
[qml] foo: [object Object]
[qml] objectName:
[qml] changeStuff: [object Object]
[qml] stuffChanged: [object Object]
[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...
> You probably have to include some checks whether the property does really
> exist
i do simple checks and have readprop/writeprop fail silently. i get nil when
reading, false from setProperty, and NoMethodError trying to assign. i guess
that's right...
> If you haven't found it already, here's the relevant C++ code from the C#
> bindings:
>
>
https://projects.kde.org/projects/kde/kdebindings/csharp/qyoto/repository/revisions/master/entry/src/qobject_interop.cpp#L373
thanks! i hadn't.
--
Sven Moritz Hallberg hallberg at pre-sense.de
Tel. +49 - 40 - 244 2407 - 28
Fax +49 - 40 - 244 2407 - 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: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20110413/aad8ccb4/attachment.sig>
More information about the Kde-bindings
mailing list