#!/usr/local/bin/ruby
require "qt2"
include Qt2

class MyDialog2 < QDialog
def initialize(parent=nil,name="",modal=false,f=0)
   setName("MyDialog2")
   resize( 411,262)
   setCaption(tr("MyDialog2"))
   setSizeGripEnabled(true)

   rgridlayout_15 = QGridLayout.new(self)
   rgridlayout_15.setMargin(11)
   rgridlayout_15.setSpacing(6)

   @listBox = QListBox.new(self)
   @listBox.setName("listBox")
   @listBox.setSizePolicy(QSizePolicy.new(0,7,sizePolicy::hasHeightForWidth()))
   @listBox.insertItem(tr("Item1"))
   @listBox.insertItem(tr("Item2"))
   @listBox.insertItem(tr("Item3"))
   rgridlayout_15.addWidget(@listBox,0,0)

   @tabWidget = QTabWidget.new(self)
   @tabWidget.setName("tabWidget")

   @Widget2 = QWidget.new(@tabWidget)
   @Widget2.setName("Widget2")

   rgridlayout_3 = QGridLayout.new(@Widget2)
   rgridlayout_3.setMargin(11)
   rgridlayout_3.setSpacing(6)

   @ButtonGroup1 = QButtonGroup.new(@Widget2)
   @ButtonGroup1.setName("ButtonGroup1")
   @ButtonGroup1.setTitle("ButtonGroup")

   @RadioButton1 = QRadioButton.new(@ButtonGroup1)
   @RadioButton1.setName("RadioButton1")
   @RadioButton1.setGeometry(11,19,98,19)
   @RadioButton1.setText(tr("RadioButton1"))

   @RadioButton2 = QRadioButton.new(@ButtonGroup1)
   @RadioButton2.setName("RadioButton2")
   @RadioButton2.setGeometry(11,44,98,19)
   @RadioButton2.setText(tr("RadioButton2"))

   @RadioButton3 = QRadioButton.new(@ButtonGroup1)
   @RadioButton3.setName("RadioButton3")
   @RadioButton3.setGeometry(11,69,98,19)
   @RadioButton3.setText(tr("RadioButton3"))

   @RadioButton4 = QRadioButton.new(@ButtonGroup1)
   @RadioButton4.setName("RadioButton4")
   @RadioButton4.setGeometry(11,94,98,19)
   @RadioButton4.setText(tr("RadioButton4"))
   rgridlayout_3.addWidget(@ButtonGroup1,0,0)

   @Widget3 = QWidget.new(@tabWidget)
   @Widget3.setName("Widget3")

   rgridlayout_4 = QGridLayout.new(@Widget3)
   rgridlayout_4.setMargin(11)
   rgridlayout_4.setSpacing(6)

   @ButtonGroup3 = QButtonGroup.new(@Widget3)
   @ButtonGroup3.setName("ButtonGroup3")
   @ButtonGroup3.setTitle("ButtonGroup")

   @CheckBox3 = QCheckBox.new(@ButtonGroup3)
   @CheckBox3.setName("CheckBox3")
   @CheckBox3.setGeometry(10,80,181,20)
   @CheckBox3.setText(tr("CheckBox3"))

   @CheckBox4 = QCheckBox.new(@ButtonGroup3)
   @CheckBox4.setName("CheckBox4")
   @CheckBox4.setGeometry(10,110,181,20)
   @CheckBox4.setText(tr("CheckBox4"))

   @CheckBox2 = QCheckBox.new(@ButtonGroup3)
   @CheckBox2.setName("CheckBox2")
   @CheckBox2.setGeometry(10,50,181,20)
   @CheckBox2.setText(tr("CheckBox2"))

   @CheckBox1 = QCheckBox.new(@ButtonGroup3)
   @CheckBox1.setName("CheckBox1")
   @CheckBox1.setGeometry(10,20,181,20)
   @CheckBox1.setText(tr("CheckBox1"))
   rgridlayout_4.addWidget(@ButtonGroup3,0,0)

   @Widget4 = QWidget.new(@tabWidget)
   @Widget4.setName("Widget4")

   rgridlayout_11 = QGridLayout.new(@Widget4)
   rgridlayout_11.setMargin(11)
   rgridlayout_11.setSpacing(6)

   @LineEdit1 = QLineEdit.new(@Widget4)
   @LineEdit1.setName("LineEdit1")
   @LineEdit1.setText(tr("Test String"))
   rgridlayout_11.addWidget(@LineEdit1,0,0)

   @SpinBox1 = QSpinBox.new(@Widget4)
   @SpinBox1.setName("SpinBox1")
   rgridlayout_11.addWidget(@SpinBox1,1,0)

   @Slider1 = QSlider.new(@Widget4)
   @Slider1.setName("Slider1")
   @Slider1.setOrientation(Qt::Horizontal)
   rgridlayout_11.addWidget(@Slider1,2,0)

   @LCDNumber1 = QLCDNumber.new(@Widget4)
   @LCDNumber1.setName("LCDNumber1")
   rgridlayout_11.addWidget(@LCDNumber1,2,1)

   @ComboBox1 = QComboBox.new(@Widget4)
   @ComboBox1.setName("ComboBox1")
   @ComboBox1.insertItem(tr("Item1"))
   @ComboBox1.insertItem(tr("Item2"))
   @ComboBox1.insertItem(tr("Item3"))
   rgridlayout_11.addWidget(@ComboBox1,3,0)

   @Spacer1_8 = QSpacerItem.new( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum )
   rgridlayout_11.addItem(@Spacer1_8,3,0)

   @Spacer2_9 = QSpacerItem.new( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum )
   rgridlayout_11.addItem(@Spacer2_9,3,0)

   @Spacer3_10 = QSpacerItem.new( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum )
   rgridlayout_11.addItem(@Spacer3_10,3,0)

   @tabWidget.insertTab(@Widget2,tr("Tab Item1"))

   @tabWidget.insertTab(@Widget3,tr("Tab Item2"))

   @tabWidget.insertTab(@Widget4,tr("Tab Item3"))
   rgridlayout_15.addWidget(@tabWidget,0,1)

   @privateLayoutWidget_14 = self
   @privateLayoutWidget_14.setName("Layout1")

   @Layout1 = QHBoxLayout.new(nil)
   @Layout1.setMargin(0)
   @Layout1.setSpacing(6)

   @buttonHelp = QPushButton.new(@privateLayoutWidget_14)
   @buttonHelp.setName("buttonHelp")
   @buttonHelp.setText(tr("&Help"))
   @buttonHelp.setAutoDefault(true)

   @Layout1.addWidget(@buttonHelp,0)

   @Horizontal_Spacing2_12 = QSpacerItem.new( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum )

   @Layout1.addItem(@Horizontal_Spacing2_12)

   @buttonApply = QPushButton.new(@privateLayoutWidget_14)
   @buttonApply.setName("buttonApply")
   @buttonApply.setText(tr("&Apply"))
   @buttonApply.setAutoDefault(true)

   @Layout1.addWidget(@buttonApply,0)

   @buttonOk = QPushButton.new(@privateLayoutWidget_14)
   @buttonOk.setName("buttonOk")
   @buttonOk.setText(tr("&OK"))
   @buttonOk.setAutoDefault(true)
   @buttonOk.setDefault(true)

   @Layout1.addWidget(@buttonOk,0)

   @buttonCancel = QPushButton.new(@privateLayoutWidget_14)
   @buttonCancel.setName("buttonCancel")
   @buttonCancel.setText(tr("&Cancel"))
   @buttonCancel.setAutoDefault(true)

   @Layout1.addWidget(@buttonCancel,0)
   rgridlayout_15.addMultiCellLayout(@Layout1,1,1,0,1)

#connections of main form
   
   Qt2::connect(@buttonOk, QSIGNAL("clicked()"), self, QSLOT("accept()"))   
   Qt2::connect(@buttonCancel, QSIGNAL("clicked()"), self, QSLOT("reject()"))   
   Qt2::connect(@listBox, QSIGNAL("selected(int)"), self, "showTab(int)")   
   Qt2::connect(@Slider1, QSIGNAL("valueChanged(int)"), @LCDNumber1, QSLOT("display(int)"))

#taborders
end


def showTab(arg = nil)   # (int) expected
   QMessageBox::information(nil,"Unimplemented slot","showTab(int) is not implemented.")
end
end
#main roop for displaying form

a = QApplication.new([$0]+ARGV)
codec = QTextCodec.codecForName('UTF-8')
a.setDefaultCodec(codec)
#for close to quit program
Qt2::connect(QApplication::qApp,QSIGNAL("lastWindowClosed()"),
   QApplication::qApp,QSLOT("quit()"))
myform = MyDialog2.new
a.setMainWidget(myform)
myform.show()
a.exec
