QtRuby:复选框没有切换

时间:2016-02-09 01:00:41

标签: ruby qt qtruby

我创建了一个带有标签AVS的复选框。当我单击复选框时,我需要执行下面的代码块。我既没有得到任何错误,也没有切换工作。

require 'Qt'
class Auth < Qt::Widget

slots 'on_toggled(bool)'

def initialize(parent=nil)
  super(parent)
  setWindowTitle("Org");
  setFixedSize 750,530

  avs_ui

  show 

end 

def avs_ui
  @label = Qt::Label.new "AVS?: ", self 
  @label.setFont Qt::Font.new("Times New Roman", 14)
  cb = Qt::CheckBox.new " ",self 
  cb.setChecked false 
  connect cb, SIGNAL("toggled(bool)"), self, SLOT("on_toggled(bool)")
  @label.move 65,130
  cb.move 170,130
end 

def on_toggled state 
   if state 

   @lineedit = Qt::LineEdit.new(self)
   @lineedit.setFont Qt::Font.new("Times New Roman", 12)
   @label = Qt::Label.new "Address: ", self 
   @label.setFont Qt::Font.new("Times New Roman", 14)
   @label.move 380,130
   @label.resize 170,20
   @lineedit.move 500,130

   @lineedit1 = Qt::LineEdit.new(self)
   @lineedit1.setFont Qt::Font.new("Times New Roman", 12)
   @label1 = Qt::Label.new "Zip Code: ", self 
   @label.setFont Qt::Font.new("Times New Roman", 14)
   @label.move 420,160
   @label.resize 70,20
   @lineedit.move 500,160
   end 
end 

end 

app = Qt::Application.new(ARGV)
widget = Auth.new
widget.show
app.exec

有人可以让我知道我应该做出哪些更改,以便当我点击复选框时,我会获得其他所需的小部件吗?

0 个答案:

没有答案