From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- examples/process/README | 8 ++ examples/process/process.cpp | 94 +++++++++++++++++++ examples/process/process.doc | 20 ++++ examples/process/process.pro | 11 +++ examples/process/small_dialog.ui | 197 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 330 insertions(+) create mode 100644 examples/process/README create mode 100644 examples/process/process.cpp create mode 100644 examples/process/process.doc create mode 100644 examples/process/process.pro create mode 100644 examples/process/small_dialog.ui (limited to 'examples/process') diff --git a/examples/process/README b/examples/process/README new file mode 100644 index 000000000..55a2d02f3 --- /dev/null +++ b/examples/process/README @@ -0,0 +1,8 @@ +The process example is not particularly useful, but it shows a typical +use of the class QProcess. + +This example starts the uic command with some options and displays the +output of the uic call. The uic is a command line tool that is used if you +create dialogs with the Qt Designer. If you installed Qt correctly, it +should be available on your system. It outputs the generated code to +standard output by default. diff --git a/examples/process/process.cpp b/examples/process/process.cpp new file mode 100644 index 000000000..32368dc57 --- /dev/null +++ b/examples/process/process.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include + +class UicManager : public TQVBox +{ + Q_OBJECT + +public: + UicManager(); + ~UicManager() {} + +public slots: + void readFromStdout(); + void scrollToTop(); + +private: + TQProcess *proc; + TQTextView *output; + TQPushButton *tquitButton; +}; + +UicManager::UicManager() +{ + // Layout + output = new TQTextView( this ); + tquitButton = new TQPushButton( tr("Quit"), this ); + connect( tquitButton, SIGNAL(clicked()), + qApp, SLOT(tquit()) ); + resize( 500, 500 ); + + // TQProcess related code + proc = new TQProcess( this ); + + // Set up the command and arguments. + // On the command line you would do: + // uic -tr i18n "small_dialog.ui" + proc->addArgument( "uic" ); + proc->addArgument( "-tr" ); + proc->addArgument( "i18n" ); + proc->addArgument( "small_dialog.ui" ); + + connect( proc, SIGNAL(readyReadStdout()), + this, SLOT(readFromStdout()) ); + connect( proc, SIGNAL(processExited()), + this, SLOT(scrollToTop()) ); + + if ( !proc->start() ) { + // error handling + TQMessageBox::critical( 0, + tr("Fatal error"), + tr("Could not start the uic command."), + tr("Quit") ); + exit( -1 ); + } +} + +void UicManager::readFromStdout() +{ + // Read and process the data. + // Bear in mind that the data might be output in chunks. + output->append( proc->readStdout() ); +} + +void UicManager::scrollToTop() +{ + output->setContentsPos( 0, 0 ); +} + +int main( int argc, char **argv ) +{ + TQApplication a( argc, argv ); + UicManager manager; + a.setMainWidget( &manager ); + manager.show(); + return a.exec(); +} + +#include "process.moc" diff --git a/examples/process/process.doc b/examples/process/process.doc new file mode 100644 index 000000000..d02b855f3 --- /dev/null +++ b/examples/process/process.doc @@ -0,0 +1,20 @@ +/* +*/ + +/*! \page process-example.html + + \ingroup qprocess-examples + + \title Starting processes with IO redirection + + This example shows you how to start other processes with Qt and how + IO redirection is done. The example tries to start the uic (a tool + that comes with the Qt Designer) on a certain ui file and displays the + output of the command. + +
+ + Implementation (process.cpp): + + \include process/process.cpp +*/ diff --git a/examples/process/process.pro b/examples/process/process.pro new file mode 100644 index 000000000..ba5fb24b0 --- /dev/null +++ b/examples/process/process.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = process + +CONFIG += qt warn_on release +DEPENDPATH = ../../include + +REQUIRES = large-config + +HEADERS = +SOURCES = process.cpp +INTERFACES = diff --git a/examples/process/small_dialog.ui b/examples/process/small_dialog.ui new file mode 100644 index 000000000..47d9109dc --- /dev/null +++ b/examples/process/small_dialog.ui @@ -0,0 +1,197 @@ + +SmallDialog + + + SmallDialog + + + + 0 + 0 + 361 + 283 + + + + Small Dialog + + + true + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + buttonHelp + + + &Help + + + true + + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + buttonOk + + + OK + + + 0 + + + true + + + true + + + + + buttonCancel + + + Cancel + + + 0 + + + true + + + + + + + TextLabel1 + + + + 1 + 0 + + + + This is just a useless dialog. + + + + + Frame4 + + + StyledPanel + + + Raised + + + + unnamed + + + 11 + + + 6 + + + + Dial1 + + + + + LCDNumber1 + + + 2 + + + + + Slider1 + + + Vertical + + + + + + + + + buttonOk + clicked() + SmallDialog + accept() + + + buttonCancel + clicked() + SmallDialog + reject() + + + Slider1 + valueChanged(int) + LCDNumber1 + display(int) + + + Slider1 + valueChanged(int) + Dial1 + setValue(int) + + + Dial1 + valueChanged(int) + Slider1 + setValue(int) + + + -- cgit v1.2.1