// Name : Qt TextView // Author : Terrence Ma // Email : terrence@terrence.com // Web : http://www.terrence.com // Date : V1.0 03/16/2003 // License : GNU GPL - http://www.gnu.org/copyleft/gpl.html // Warranty : No Warranty #include #include #include #include int main( int argc, char* argv[] ) { QApplication myapp( argc, argv ); // see Programming with Qt Example 11-1 p.249 if( argc != 2 ) { qDebug( "Usage: TextView filename\n" ); return 1; } QFile file( argv[1] ); if( !file.open( IO_ReadOnly ) ) { qDebug( "Error: file not found\n" ); return 1; } QTextStream stream( &file ); QString filetext = stream.read(); file.close(); // while( !stream.eof() ) { // line = stream.readLine(); // qDebug( "%s", line.data() ); // } QTextBrowser mytext; mytext.setText( filetext ); mytext.resize( 600, 300 ); myapp.setMainWidget( &mytext ); mytext.show(); return myapp.exec(); }