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

Yaohan Chen yaohan.chen at gmail.com
Wed Feb 22 20:56:55 UTC 2012


Thank you for the reply. I haven't created a C or C++ extension for Ruby
either, but there seem to be plenty of resources on that. But assuming I'm
ready to write the extension, would I just need to define these Quassel
types in the extension, and their operator<< and operator>>? Would
QDataStream automatically use them, and know that the types I define
should correspond to the ones serialized in the stream?

On Wednesday, February 22, 2012 04:50:50 PM Arno Rehn wrote:
> 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.



More information about the Kde-bindings mailing list