Advertisement
Guest User

Combo App

a guest
Mar 31st, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.55 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.     @layout = Qt::VBoxLayout.new
  11.     @layout.addWidget(@combo)
  12.  
  13.     self.windowTitle = "Combo App"
  14.     self.resize(300, 50)
  15.     self.layout = @layout
  16.   end
  17.  
  18.   def closeEvent(event)
  19.     puts @combo.currentText
  20.   end
  21.  
  22. end
  23.  
  24. if $0 == __FILE__
  25.   app = Qt::Application.new(ARGV) # you may use the QApplication lastWindowClosed
  26.   win = Window.new(('A'..'Z').to_a)
  27.   win.show
  28.   app.exec
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement