【问题标题】:QProcess gpg2 error in windowsWindows中的QProcess gpg2错误
【发布时间】:2015-10-31 14:18:02
【问题描述】:

我需要使用 Qt 使用 gpg 加密一些文本。 QCA 是别无选择。 我的函数在 Linux 中运行,但在 Windows 中我得到了 exitCode 2。

在命令行上使用相同的参数执行 gpg2.exe 会像预期的那样工作。

QString PGPProcess::encrypt(QString toAddress, QString message)
{

    this->start(QStringList() << "--trust-model always" << "-a" << "-e" << "-r " + toAddress);
    this->waitForStarted(PROCESS_WAIT);
    this->write(message.toUtf8());
    this->waitForBytesWritten(PROCESS_WAIT);
    this->closeWriteChannel();
    this->waitForFinished(PROCESS_WAIT);

    if(this->exitCode()) {
        qDebug() << this->exitCode();
        return message;
    } else {
        return this->readAllStandardOutput();
    }

}

我认为这与 closeWriteChannel() 有关。命令行必须发送 gpg 正在加密书面文本的 CRTL-D (Linux)。

在 Windows 中 CTRL-D 不做任何事情,我必须按 CTRL-C。 但是在 QProcess 上调用 terminate() 也不起作用。

【问题讨论】:

    标签: gnupg qt5.5


    【解决方案1】:

    好的,只需将参数 QStringList 更改为以下即可...

    this->start(QStringList() << "--trust-model" << "always" << "-a" << "-e" << "-r" << toAddress);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-24
      • 1970-01-01
      • 2018-04-26
      • 2014-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多