out->append(process.readAllStandardOutput());
out->append(process.readAllStandardOutput());
To copy to clipboard, switch view to plain text mode
//main.cpp
#include <QApplication>
#include "dialogimpl.h"
//
int main(int argc, char ** argv)
{
DialogImpl win;
win.show();
app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// dialogimpl.cpp
#include "dialogimpl.h"
#include <QProcess>
//
DialogImpl
::DialogImpl( QWidget * parent, Qt
::WFlags f
) {
setupUi(this);
process
->setReadChannel
(QProcess::StandardOutput);
connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(output()));
connect(pushButton, SIGNAL(clicked()), this, SLOT(runcmd()));
}
//
void DialogImpl::output()
{
textEdit->append((process->readAllStandardOutput()));
}
//
void DialogImpl::runcmd()
{
process->start(lineEdit->text());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// dialogimpl.h
#ifndef DIALOGIMPL_H
#define DIALOGIMPL_H
//
#include "ui_dialog.h"
//
class DialogImpl
: public QDialog,
public Ui
::Dialog{
Q_OBJECT
public:
DialogImpl
( QWidget * parent
= 0, Qt
::WFlags f
= 0 );
private slots:
void output();
void runcmd();
private:
};
#endif
//main.cpp
#include <QApplication>
#include "dialogimpl.h"
//
int main(int argc, char ** argv)
{
QApplication app( argc, argv );
DialogImpl win;
win.show();
app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// dialogimpl.cpp
#include "dialogimpl.h"
#include <QProcess>
//
DialogImpl::DialogImpl( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f)
{
setupUi(this);
process = new QProcess(this);
process->setReadChannel(QProcess::StandardOutput);
connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(output()));
connect(pushButton, SIGNAL(clicked()), this, SLOT(runcmd()));
}
//
void DialogImpl::output()
{
textEdit->append((process->readAllStandardOutput()));
}
//
void DialogImpl::runcmd()
{
process->start(lineEdit->text());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// dialogimpl.h
#ifndef DIALOGIMPL_H
#define DIALOGIMPL_H
//
#include "ui_dialog.h"
//
class QProcess;
class DialogImpl : public QDialog, public Ui::Dialog
{
Q_OBJECT
public:
DialogImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
private slots:
void output();
void runcmd();
private:
QProcess* process;
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks