#!/usr/local/bin/ruby

require "qt2"
include Qt2


class HelloApp < QObject

   def initialize
      @qapp = QApplication.new([$0] + ARGV)
      @button = QPushButton.new("")
      @button.setText("Hello")
      @button.resize(100,30)
      @qapp.setMainWidget(@button)
   end
   def callback
      if @button.text == "Hello"
         begin
            @button.setText("Bye")
            print "One more push quit the program\n"
         end
      else
         @qapp.quit
      end
   end
   def run
      rs = Qt2::connect(@button,QSIGNAL('clicked()'),self,'callback')
      print "#{rs.type}\n"
      @button.show
      @qapp.exec
    end
end

HelloApp.new.run
