[Kde-bindings] Understanding QtRuby

Jonathan Gardner jgardner at jonathangardner.net
Mon Apr 7 21:40:14 UTC 2008

I am no pro at Ruby. I do understand Python really well, including it's 
C interface.

I am attempting to build a package in Lisp that will allow me to connect 
with Qt, possibly using the Smoke library. So I am poking at the QtRuby 
code to get started.

However, I am completely befuddled by the most basic of statements. I am 
sure that a few pointers to the documentation would help me get on the 
right path.

Consider the example shown at 

      #!/usr/bin/ruby -w
      require 'Qt'

I believe that "require 'Qt'" loads the Qt.rb file, which simply loads the qtruby.qt file.

      a = Qt::Application.new(ARGV)

This, I believe, is a simply constructor for the Qt::Application defined at line 182 in qtruby.rb. There is no C magic yet.

      hello = Qt::PushButton.new("Hello World!", nil)

The PushButton class doesn't exist in qtruby.qt. I can't tell how this is getting dispatched.

      hello.resize(100, 30)

Pending an understanding of what PushButton is.

      a.mainWidget = hello

I can't tell how the mainWidget assignment is dispatched either.


I believe the exec method here is defined at line 183.

                def exec
                        Qt::Internal.application_terminated = true

I am not sure what this is doing. What is method_missing? where is dispose defined?

Although I can find the Qt::Internal module, I don't see how application_terminated is defined. 

I am sorry for being such a newbie when it comes to Ruby, but I think if I can get a few pointers I can get underway.

More information about the Kde-bindings mailing list