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 --- doc/html/process-example.html | 148 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 doc/html/process-example.html (limited to 'doc/html/process-example.html') diff --git a/doc/html/process-example.html b/doc/html/process-example.html new file mode 100644 index 000000000..839f185b3 --- /dev/null +++ b/doc/html/process-example.html @@ -0,0 +1,148 @@ + + + + + +Starting processes with IO redirection + + + + + + + +
+ +Home + | +All Classes + | +Main Classes + | +Annotated + | +Grouped Classes + | +Functions +

Starting processes with IO redirection

+ + +

+

This example shows you how to start other processes with TQt and how +IO redirection is done. The example tries to start the uic (a tool +that comes with the TQt Designer) on a certain ui file and displays the +output of the command. +


+

Implementation (process.cpp): +

/****************************************************************************
+** $Id: qt/process.cpp   3.3.8   edited Jan 11 14:37 $
+**
+** Copyright (C) 1992-2007 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 <qobject.h>
+#include <qprocess.h>
+#include <qvbox.h>
+#include <qtextview.h>
+#include <qpushbutton.h>
+#include <qapplication.h>
+#include <qmessagebox.h>
+
+#include <stdlib.h>
+
+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"
+
+ +

See also TQProcess Examples. + + +


+ +
Copyright © 2007 +TrolltechTrademarks +
TQt 3.3.8
+
+ -- cgit v1.2.3