#!/usr/bin/env ruby require "qte" require "qpe" include Qte include Qpe class SampleWindow < QMainWindow def initialize() super() setCaption(tr("サンプル")) @msg = QLabel.new(tr("これはサンプルプログラム"),self) @msg.setGeometry(10,10,300,30) $ebox1 = QMultiLineEdit.new(self) $ebox1.setGeometry(0,200,635,200) $ebox1.setReadOnly(true) @pb1 = QPushButton.new(tr("ボタン1"),self) @pb1.setGeometry(320,5,100,30) connect(@pb1,QSIGNAL("clicked()"), self, 'openSubWindow') end def openSubWindow sw = SubWindow.new(self) $ebox1.clear $ebox1.insertLine("Open Sub Window") res = sw.exec() $ebox1.insertLine("Close Sub Window") $ebox1.insertLine("res = " + res.to_s) end end class SubWindow < QTabDialog def initialize(parent) super( nil, "", true) setCaption(tr("サブウィンドウ")) setFixedSize(400,200) #サイズ指定 @w0 = QWidget.new( self ) #ウィジェット0作成 @w1 = QWidget.new( self ) #ウィジェット1作成 addTab( @w0, tr("ウィジェット0") ) #タブに追加 addTab( @w1, tr("ウィジェット1") ) #ウィジェット0上の配置 @msg0 = QLabel.new(tr("ウィジェット0のエリア"), @w0) @msg0.setGeometry(10,10,300,100) #ウィジェット1上の配置 @msg1 = QLabel.new(tr("ウィジェット1\nのエリア"), @w1) @msg1.setGeometry(10,10,300,100) setOkButton(tr("おっけー")) setCancelButton(tr("きゃんせる")) setApplyButton(tr("適用")) connect(self, QSIGNAL("applyButtonPressed()"), self, 'pushApply') end def pushApply $ebox1.insertLine(tr("適用が押された")) end end $defaultCodec = QTextCodec.codecForName("utf8") app = QPEApplication.new([$0]+ARGV) app.setDefaultCodec($defaultCodec) QApplication.setFont(QFont.new("lcfont",18)) app.showMainWidget(SampleWindow.new) app.exec