[Qt-interest] QProcess & gpg
Andre Somers
andre at familiesomers.nl
Tue Dec 14 07:51:09 CET 2010
Op 14-12-2010 2:41, Anthony Gabrielson schreef:
> Problem solved and it was in fact obvious...
Would you care to tell the people here what the problem was? That is
nice for educational and archiving reasons...
André
> On Dec 13, 2010, at 8:18 PM, Anthony Gabrielson wrote:
>
>> Hello,
>> I'm trying to work through an issue I'm having with QProcess& gpg and I'm hoping I'm doing something wrong thats obvious; but other commands like ls or pwd work. Anyway, I have some sample code and I'm calling gpg with a few options. The command works great from command line, but isn't working at all from within my sample app.
>>
>> Here is the code:
>>
>> MainWindow::MainWindow(QWidget *parent)
>> : QMainWindow(parent)
>> {
>> Editor *edit = new Editor(this);
>> setCentralWidget(edit);
>>
>> QString appPath = qApp->applicationDirPath();
>>
>> QString program = "gpg -e -r agabriel at ubuntu out.txt";
>> //QString program = "pwd";
>> QStringList arguments;
>> //arguments<< "-e"<< "-r agabriel at ubuntu"<< "out.txt";
>>
>> QProcess *myProcess = new QProcess(parent);
>> myProcess->start(program, arguments);
>> //myProcess->execute(program);
>> myProcess->waitForFinished(-1);
>>
>> edit->newCmd(QString("cmd: ").append(program));
>>
>> if(myProcess->exitStatus() == QProcess::NormalExit)
>> edit->newCmd("GPG: Normal Exit");
>>
>> if(myProcess->state() == QProcess::NotRunning)
>> edit->newCmd("GPG: not running");
>>
>> QString data = myProcess->readAllStandardError();
>> edit->newCmd(QString("ERR output: ").append(data));
>>
>> data = myProcess->readAllStandardOutput();
>> edit->newCmd(QString("IO output: ").append(data));
>>
>> data = myProcess->readAll();
>> edit->newCmd(QString("All output: ").append(data));
>> }
>>
>> Here is the output:
>>
>> cmd: gpg -e -r agabriel at ubuntu out.txt
>> GPG: Normal Exit
>> GPG: not running
>> ERR output:
>> IO output:
>> All output:
>>
>> Any ideas why this isn't working?
>>
>> Thanks,
>> Anthony
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list