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

Alexander Duda Alexander.Duda at dfki.de
Wed Dec 22 18:12:11 UTC 2010

Am 22.12.2010 um 18:06 schrieb Alex:
>> 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! :)
> I don't seem to see phonon in the qt ruby source.  I'm using the gem
> 'qtbindings' but referencing the source qt4-qtruby-2.1.0 to try to
> find examples.  I don't even see a download for phonon on the phonon
> page..

An other way to get access to your qt derived c++ class is using slots and the qt plugin loader (see example below or http://doc.qt.nokia.com/stable/qpluginloader.html). After loading the plugin you have full access to all slots of your class on the ruby side without the need of user specific bindings.

def load_widget_factory(path)
    loader = Qt::PluginLoader.new(path)
    if !loader.isLoaded 
      puts "Cannot load #{path}. Last error is: #{loader.errorString}"
      return nil
    factory_instance = loader.instance
    if factory_instance == nil
      puts "Could not load widget plugin #{loader.fileName}. Last error is: #{loader.errorString}"
      return nil

Alex D.

More information about the Kde-bindings mailing list