Wednesday, January 26, 2011

Programming QtRuby (2) - Open a Dialog

1. Main program.

# main.rb
require 'rubygems'
require 'Qt'
require 'dialogwindow.rb' 

class QtApp < Qt::Application
 
 include DialogWindowModule
 
 def initialize(argv)
  super(argv)
  d = SimpleDialog.new
  d.show
  self.exec
 end
end

QtApp.new ARGV


2. DialogWindow Module
# dialogwindow.rb
require 'Qt'
module DialogWindowModule

 class SimpleDialog < Qt::Dialog
  def initialize
   super
   self.resize 300,200
   self.setWindowTitle 'Dialog Test'
  end
 end

end
3. Run it to see the result.

No comments:

Post a Comment