Re: Quick help on QProcess
I think is valid:
Code:
out->append(process.readAllStandardOutput());
I'm try create simple application when using QProcess class,
but I didn't receive output buffer.
Code:
//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
Where I was mistaken?
Re: Quick help on QProcess
What happens if you add:
Code:
connect( process,
SIGNAL(started
()),
QCoreApplication::instance(),
SLOT(aboutQt
()) );
at the end of dialog's constructor?
Re: Quick help on QProcess
Strange situation,
if I run "calc.exe" (for example), it's working (calculator running) and About dialog was shown.
If I run "dir", it's not working, and About dialog was not shown.
:eek:
Re: Quick help on QProcess
But dir is not a real application. It is just built in command prompt.
On the other hand, calc is an application and can be a process.
If you want to use command scripting, then use batch files. Execute them like this:
"cmd.exe my_batchFile.bat"
Regards
Re: Quick help on QProcess
It is very a shame to me. I have absolutely forgotten it.:-(.
Many thanks
Re: Quick help on QProcess
And one question,
when started program,
CONSOLE dialog was shown. Can I to get rid of it?
I'm planned run console commands and taking output from console,
but I do not need to be shown the console thus.
Re: Quick help on QProcess
No, I don't think you can do that.
You cannot run cmd without the window.
Regards
Re: Quick help on QProcess
It is a pity.
But the problem not only at use CMD, at start of the program (which uses QProcess) console dialog was shown :-(.
Re: Quick help on QProcess
The question is solved.
A problem in absence of a patch for hands :))