Languages/Ruby/Ruby-Qt/KDE Book/First Steps/Hello World

From KDE TechBase
Revision as of 22:36, 19 January 2010 by Robert Riemann (talk | contribs) (add some code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Ruby-Qt/KDE Book
Tutorial Series   Ruby
Previous   Installation on Linux, Installation on Mac OS or Installation on Windows
What's Next   n/a
Further Reading   n/a
100%
noframe
noframe

0% completed (estimate)

  

Status Of Writing


After all you should have a working ruby installation with KDE 4 bindings.

So lets try the a very minimalistic KDE 4 application to get a first impression.

Interactive Hello Ruby

Implementation Using Qt 4

require 'Qt4'

a = Qt::Application.new ARGV w = Qt::PushButton.new( "Click me to quit" ) do

 connect( SIGNAL :clicked ) do
   puts "Do something else"
   Qt::Application.instance.quit
 end

end w.show a.exec

require 'Qt4'

a = Qt::Application.new ARGV w = Qt::PushButton.new( "Click me to quit" ) w.connect( SIGNAL :clicked ) do

   puts "Do something else"
   Qt::Application.instance.quit

end w.show a.exec

require 'Qt4'

class Qt::Application

 slots :doSomething
 def doSomething
   puts "Do something else"
   Qt::Application.instance.quit    
 end
 

end

a = Qt::Application.new ARGV w = Qt::PushButton.new( "Click me to quit" ) w.connect( SIGNAL :clicked, a, SLOT :doSomething) w.show a.exec