1

約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 

これで、スロット 'on_clicked_submit()' に接続された Submit というボタンができました。

entryIndex 項目がカスタムまたは非カスタムの場合にのみ、ダイアログ ボックスがポップアップするようにします。次のコードを試しました:

  def on_clicked_submit 
      if $entryIndex == 1 || $entryIndex == 8 
      text = Qt::InputDialog.getText self, "Swipe", "Thank you"
  end 

終わり

しかし、entryIndex をチェックする if ステートメントがうまく機能していませんでした。提案は大歓迎です

4

0 に答える 0