[Kde-bindings] Re: custom qt derived c++ class example for qtruby

Arno Rehn arno at arnorehn.de
Wed Dec 22 12:28:30 UTC 2010


On Wednesday 22 December 2010 04:14:49 Vincent Batts wrote:
> from the kdebindings/ruby/qtruby/examples/ check out
> ./examples/dialogs/simplewizard/classwizard.rb
> ./examples/mainwindows/mdi/mainwindow.rb
> they both use QWidget
> 
> as for QGraphicsItem, i don't think it is available in qtruby yet.
Of course it's available. QtRuby supports nearly all Qt classes.
I think Alex' question was a different one anyway.

> On Tue, Dec 21, 2010 at 9:55 PM, Alex <x37v.alex at gmail.com> wrote:
> > Does anyone have a simple example project where you wrap a qt derived
> > class, QWidget or QGraphicsItem, .. and use it on the ruby side with
> > qtruby?
> > 
> > I figure there are a few steps, the smoke wrapping, probably some code
> > or tool to do the ruby wrapping, and compiling... but, it is kind of
> > unclear to me how people actually do it.
> > 
> > I have seen a lot of talk of it being possible but I haven't seen any
> > actual examples which do it, I figure that would be very useful for a
> > number of other folks as well.
If you only have one or two classes to expose, the following might be much 
easier:
http://pcapriotti.wordpress.com/2010/12/06/effective-qt-in-ruby-part-3-2/

But if you instead want to wrap a whole library, the Smoke approach is much 
better. Docs on how to create a Smoke library can be found here:
http://techbase.kde.org/Development/Languages/Smoke

Looking at existing ones isn't a bad idea either :)

You still need to create a ruby extension to tell QtRuby to actually load that 
additional Smoke library. That's fairly easy, just look at some of the simple 
extensions in the QtRuby source (Phonon for example). If you have more 
questions, don't hesitate to ask! :)

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list