#!/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,280,635,120) @ebox1.setReadOnly(true) @pb1 = QPushButton.new(tr("ボタン1"),self) @pb1.setGeometry(320,5,100,30) connect(@pb1,QSIGNAL("clicked()"), self, 'openSubWindow') end def openSubWindow # $pushPB = 0 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) @ebox1.insertLine("pushPB = " + sw.pushPB?.to_s) # @ebox1.insertLine("$pushPB = " + $pushPB.to_s) end def xxx close() end end class SubWindow < QDialog def initialize(parent) #parentが必要 # super() super( nil, "", true) setCaption(tr("サブウィンドウ")) setFixedSize(400,200) #サイズ指定 @pb = QPushButton.new(tr("閉じる"),self) @pb.setGeometry(150,85,100,30) connect(@pb,QSIGNAL("clicked()"), self, 'closeSubWindow') @pushPB = 0 end def closeSubWindow close() @pushPB = 1 # $pushPB = 1 end def pushPB? return @pushPB 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