(add some code) |
(insert code examples, code works) |
||
| Line 20: | Line 20: | ||
a = Qt::Application.new ARGV | a = Qt::Application.new ARGV | ||
| − | w = Qt::PushButton.new( " | + | w = Qt::PushButton.new( "Hello Ruby" ) |
| − | + | Qt::Object.connect( w, SIGNAL( :clicked ), a, SLOT( :quit ) ) | |
| + | w.show | ||
| + | a.exec | ||
| + | </code> | ||
| + | |||
| + | |||
| + | <code ruby> | ||
| + | require 'Qt4' | ||
| + | |||
| + | class CustomApplication < Qt::Application | ||
| + | |||
| + | slots :doSomething | ||
| + | |||
| + | def doSomething | ||
puts "Do something else" | puts "Do something else" | ||
Qt::Application.instance.quit | Qt::Application.instance.quit | ||
end | end | ||
| + | |||
end | end | ||
| + | |||
| + | a = CustomApplication.new ARGV | ||
| + | w = Qt::PushButton.new( "Hello Ruby" ) | ||
| + | Qt::Object.connect( w, SIGNAL( :clicked ), a, SLOT( :doSomething ) ) | ||
w.show | w.show | ||
a.exec | a.exec | ||
| Line 34: | Line 52: | ||
a = Qt::Application.new ARGV | a = Qt::Application.new ARGV | ||
| − | w = Qt::PushButton.new( " | + | w = Qt::PushButton.new( "Hello Ruby" ) |
w.connect( SIGNAL :clicked ) do | w.connect( SIGNAL :clicked ) do | ||
puts "Do something else" | puts "Do something else" | ||
| Line 46: | Line 64: | ||
require 'Qt4' | require 'Qt4' | ||
| − | + | a = Qt::Application.new ARGV | |
| − | + | w = Qt::PushButton.new( "Hello Ruby" ) do | |
| − | + | connect( SIGNAL :clicked ) do | |
| − | + | ||
| − | + | ||
puts "Do something else" | puts "Do something else" | ||
| − | Qt::Application.instance.quit | + | Qt::Application.instance.quit |
end | end | ||
| − | |||
end | end | ||
| − | |||
| − | |||
| − | |||
| − | |||
w.show | w.show | ||
a.exec | a.exec | ||
</code> | </code> | ||
| Tutorial Series | Ruby |
| Previous | Installation on Linux, Installation on Mac OS or Installation on Windows |
| What's Next | n/a |
| Further Reading | n/a |
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.
require 'Qt4'
a = Qt::Application.new ARGV w = Qt::PushButton.new( "Hello Ruby" ) Qt::Object.connect( w, SIGNAL( :clicked ), a, SLOT( :quit ) ) w.show a.exec
require 'Qt4'
class CustomApplication < Qt::Application
slots :doSomething
def doSomething puts "Do something else" Qt::Application.instance.quit end
end
a = CustomApplication.new ARGV w = Qt::PushButton.new( "Hello Ruby" ) Qt::Object.connect( w, SIGNAL( :clicked ), a, SLOT( :doSomething ) ) w.show a.exec
require 'Qt4'
a = Qt::Application.new ARGV w = Qt::PushButton.new( "Hello Ruby" ) w.connect( SIGNAL :clicked ) do
puts "Do something else" Qt::Application.instance.quit
end w.show a.exec
require 'Qt4'
a = Qt::Application.new ARGV w = Qt::PushButton.new( "Hello Ruby" ) do
connect( SIGNAL :clicked ) do puts "Do something else" Qt::Application.instance.quit end
end w.show a.exec