#!/usr/local/ruby

require "qt"
include Qt

class MyWidget < QWidget
def initialize
   bt1 = QPushButton.new("Hide me",self)
   Qt::connect(bt1,QSIGNAL("clicked()"),bt1,QSLOT("hide()"))
   bt1.setGeometry(0,0,100,30)
   
   bt2 = QPushButton.new("Show BT",self)
   Qt::connect(bt2,QSIGNAL("clicked()"),bt1,QSLOT("show()"))
   bt2.setGeometry(110,0,100,30)
   
   
   @bt3 = QPushButton.new("Delete me",self)
   Qt::connect(@bt3,QSIGNAL("clicked()"),self,"delete_bt3")
   @bt3.setGeometry(0,35,100,30)
   
end

def delete_bt3
   @bt3.hide
   @bt3.delete
print @bt3;print "\n"
   @bt3 = nil
print @bt3;print "\n"
   GC.start
end

end

a = QApplication.new([$0]+ARGV)
w = MyWidget.new
a.setMainWidget(w)
w.show
a.exec

