#!/usr/bin/perl -w # Name : PerlQt TextView # Author : Terrence Ma # Email : terrence@terrence.com # Web : http://www.terrence.com # Date : V1.0 04/06/2003 # License : GNU GPL - http://www.gnu.org/copyleft/gpl.html # Warranty : No Warranty # see http://www.terrence.com/qt/textview/textview.html # Qt::String not allowed with strict, Qt::String() not parsed in Qt.pm # use strict; use Qt; my($myapp, $filename, $IO_ReadOnly, $file, $stream, $filetext, $mytext); $myapp = Qt::Application(\@ARGV); $filename = $ARGV[0]; if (!($filename)) { print("Usage: textview.pl filename\n"); exit(0); } $IO_ReadOnly = 1; $file = Qt::File($filename); if (!($file->open($IO_ReadOnly))) { print("Error: file not found\n"); exit(0); } $stream = Qt::TextStream($file); $filetext = Qt::String; $filetext = $stream->read(); $file->close(); # mimesource # $mytext->setSource("file:///root/bin/perlqt/textview/f01.txt"); $mytext = Qt::TextBrowser(); $mytext->setText($filetext); $mytext->resize(600, 300); $myapp->setMainWidget($mytext); $mytext->setCaption("PerlQt TextView"); $mytext->show(); exit $myapp->exec();