summaryrefslogtreecommitdiffstats
path: root/examples/process
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
committerTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/process
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/process')
-rw-r--r--examples/process/README8
-rw-r--r--examples/process/process.cpp94
-rw-r--r--examples/process/process.doc20
-rw-r--r--examples/process/process.pro11
-rw-r--r--examples/process/small_dialog.ui197
5 files changed, 330 insertions, 0 deletions
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 <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"
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.
+
+ <hr>
+
+ 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 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>SmallDialog</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SmallDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>361</width>
+ <height>283</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Small Dialog</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonHelp</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name" stdset="0">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="accel">
+ <number>0</number>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ <property name="accel">
+ <number>0</number>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>This is just a useless dialog.</string>
+ </property>
+ </widget>
+ <widget class="TQFrame" row="1" column="0">
+ <property name="name">
+ <cstring>Frame4</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQDial" row="0" column="1">
+ <property name="name">
+ <cstring>Dial1</cstring>
+ </property>
+ </widget>
+ <widget class="TQLCDNumber" row="1" column="1">
+ <property name="name">
+ <cstring>LCDNumber1</cstring>
+ </property>
+ <property name="numDigits">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="TQSlider" row="0" column="0" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>Slider1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>SmallDialog</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SmallDialog</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>Slider1</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>LCDNumber1</receiver>
+ <slot>display(int)</slot>
+ </connection>
+ <connection>
+ <sender>Slider1</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>Dial1</receiver>
+ <slot>setValue(int)</slot>
+ </connection>
+ <connection>
+ <sender>Dial1</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>Slider1</receiver>
+ <slot>setValue(int)</slot>
+ </connection>
+</connections>
+</UI>