From bd0f3345a938b35ce6a12f6150373b0955b8dd12 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 10 Jul 2011 15:24:15 -0500 Subject: Add Qt3 development HEAD version --- 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 0000000..55a2d02 --- /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 0000000..504b8bf --- /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 Qt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include + +class UicManager : public QVBox +{ + Q_OBJECT + +public: + UicManager(); + ~UicManager() {} + +public slots: + void readFromStdout(); + void scrollToTop(); + +private: + QProcess *proc; + QTextView *output; + QPushButton *quitButton; +}; + +UicManager::UicManager() +{ + // Layout + output = new QTextView( this ); + quitButton = new QPushButton( tr("Quit"), this ); + connect( quitButton, SIGNAL(clicked()), + qApp, SLOT(quit()) ); + resize( 500, 500 ); + + // QProcess related code + proc = new QProcess( 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 + QMessageBox::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 ) +{ + QApplication 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 0000000..d02b855 --- /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 0000000..ba5fb24 --- /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 0000000..dcd7845 --- /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.3