[Kde-bindings] custom ruby objects and QVariant

Robert Riemann robert.riemann at physik.hu-berlin.de
Sun Jul 18 00:48:38 UTC 2010


Hi all,

I have to transport a custom ruby Object from a model to a 
QStyledItemDelegate. Therefor I am using
QModelIndexy#data(CustomRole) function.

In the wiki I found to proposals for wrapping own objects into a Variant.
The first one doesnt work, because #data(role) seems to transform the 
RubyVariant into a QVariant and this way the backpacker value gets lost.

The second way is more promising:
http://techbase.kde.org/Development/Languages/Ruby#Alternate_way_to_emit_Ruby_Classes

Unfortunatly I run into this error:
/usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2241:in `initialize': integer 
69920177469160 too big to convert to `int' (RangeError)
        from /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2241:in `initialize'
        from /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2640:in `call'
        from /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2640:in 
`try_initialize'
        from /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2639:in `catch'
        from /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2639:in 
`try_initialize'
        from ./main.rb:23:in `new'
        from ./main.rb:23:in `to_variant'


I got it fixed wtih a dirty hack:
Qt::Variant.new object_id.to_f instead of Qt::Variant.new object_id.to_f

How can this be done without using Floats?

Best regards,
Robert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20100718/66e7e05e/attachment.sig>


More information about the Kde-bindings mailing list