#!/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,250,635,150) $ebox1.setReadOnly(true) @pb1 = QPushButton.new(tr("SubWindow"),self) @pb1.setGeometry(320,5,100,30) connect(@pb1,QSIGNAL("clicked()"), self, 'openSubWindow') end def openSubWindow $ebox1.clear sw = SubWindow.new(self) res = sw.exec() end def xxx close() end end class SubWindow < QDialog def initialize(parent) #parentが必要 super() setCaption(tr("サブウィンドウ")) setFixedSize(400,200) #サイズ指定 @pb = QPushButton.new(tr("閉じる"),self) @pb.setGeometry(150,85,100,30) connect(@pb,QSIGNAL("clicked()"), self, 'closeSubWindow') @pb2 = QPushButton.new(tr("test"),self) @pb2.setGeometry(150,120,100,30) catchEvent() #キャッチイベント end def closeSubWindow close() end def closeEvent(e) $ebox1.insertLine("close event") close() e.accept() #これが無いとクローズしない end def moveEvent(e) $ebox1.setText("move event") 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