我有一个下拉菜单,里面有大约5-6个项目。
require 'Qt'
class Auth < Qt::Widget
entryIndex = $entryIndex
slots 'slotFunctionChanged(int)'
def initialize(parent=nil)
super(parent)
setWindowTitle("Action");
setFixedSize 750,530
entry_ui
show
end
def entry_ui
@entryLabel = Qt::Label.new "Entry: ", self
@entryLabel.setFont Qt::Font.new("Times New Roman", 14)
combo = Qt::ComboBox.new self
combo.setFont Qt::Font.new("Times New Roman", 12 )
combo.addItem "1- Standard"
combo.addItem "2- Custom"
combo.addItem "3- Non-custom"
combo.addItem "4- Non-Standard"
connect combo, SIGNAL('activated(int)'), self, SLOT('slotEntryChanged(int)')
combo.resize 170,20
combo.move 170,100
@funLabel.move 95,100
end
def slotEntryChanged(entryIndex)
case entryIndex
when 0
@acc.show
when 1
@acc.hide
when 2
@acc.show
end
end
现在有一个名为Submit的按钮,它连接到slot&#39; on_clicked_submit()&#39;。
我希望只有当entryIndex项为自定义或非自定义时才会弹出一个对话框。我尝试了以下代码:
def on_clicked_submit
if $entryIndex == 1 || $entryIndex == 8
text = Qt::InputDialog.getText self, "Swipe", "Thank you"
end
结束
但检查entryIndex的if语句不能正常工作。欢迎提出建议