[Kde-bindings] How to unserialize types defined in other Qt apps in QtRuby?

Arno Rehn arno at arnorehn.de
Wed Feb 22 15:50:50 UTC 2012


On Tuesday 21 February 2012 22:35:42 Yaohan Chen wrote:
> Hello,
> 
> How can I unserialize objects of types defined in a C++ Qt app, through a
> Qt::DataStream in QtRuby?
> 
> I am trying to create a scripting interface for the Qt IRC client Quassel
> <http://quasselirc.org>. Quassel'score connects to IRC networks, and its
> client
> displays its user interface. The two communicate through a socket, sending
> QVariant maps and lists to each other, and each map or list is prefixed with
> a uint32 indicating its size in the socket. My QtRuby client is able to
> read some of the messages sent by core, but not the ones containing types
> defined by Quassel. These messages show up as empty Qt maps. My code is at
> <https://github.com/hagabaka/Quassel-Ruby> if it's of any interest.
> 
> It seems that normally qRegisterMetaType would be used for this, but I'm not
> sure how to call a template function QtRuby. I don't have much experience
> with C++ Qt programming either, but I would appreciate any pointers.
If the types in question are custom Quassel types, you're pretty much out of 
luck, I'm afraid.
Quassel then uses custom operator<< and operator>> for serializing these types 
which the QtRuby runtime can't know about.
You could create a wrapper C++ library for those operators only and then call 
them from Ruby - Paolo has written a nice blog entry about easy C++ interop: 
http://pcapriotti.wordpress.com/2010/12/06/effective-qt-in-ruby-part-3-2/

I can't think of any other quick solution now.

-- 
Arno Rehn


More information about the Kde-bindings mailing list