Advertisement
Guest User

Combo app with quit button

a guest
Apr 2nd, 2015
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.67 KB | None | 0 0
  1. require 'Qt4'
  2.  
  3. class Window < Qt::Widget
  4.  
  5.   def initialize(values)
  6.     super(nil) # no parent
  7.  
  8.     @combo = Qt::ComboBox.new
  9.     @combo.addItems(values)
  10.  
  11.     @btn = Qt::PushButton.new('Quit')
  12.     @btn.connect(SIGNAL(:clicked)) { self.close() }
  13.  
  14.     @layout = Qt::VBoxLayout.new
  15.     @layout.addWidget(@combo)
  16.     @layout.addWidget(@btn)
  17.  
  18.     self.windowTitle = "Combo App"
  19.     self.resize(300, 50)
  20.     self.layout = @layout
  21.   end
  22.  
  23.   def closeEvent(event)
  24.     puts @combo.currentText
  25.   end
  26.  
  27. end
  28.  
  29. if $0 == __FILE__
  30.   app = Qt::Application.new(ARGV) # you may use the QApplication lastWindowClosed
  31.   win = Window.new(('A'..'Z').to_a)
  32.   win.show
  33.   app.exec
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement