#!/usr/local/bin/ruby

require "qt2"
include Qt2


class HelloApp < QObject

   def initialize
      @qapp = QApplication.new([$0] + ARGV)
      @button = QPushButton.new("")
      @button.setText(QString::fromLocal8Bit("こんにちは"))
      @button.resize(100,30)
      @qapp.setMainWidget(@button)
      @first = true
   end
   def callback
#      if @button.textAsQString.ascii == QString::fromLocal8Bit("こんにちは").ascii
       if @first
          @first = false
          @button.setText(QString::fromLocal8Bit("さようなら"))
          print "もう一度押したら終了\n"
      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
