为什么我无法获得价值形式QProcess使用readyReadStandardOutput信号

时间:2013-05-14 03:55:45

标签: qt console qprocess

我正在使用clientupdate.exe更新我的客户端,因此有一个函数“getVersion”来获取最新的版本号:

Execute::Execute(QObject *parent) :
    QObject(parent)
{
    f=Father::GetInstance();
    ftp=new FtpProvider(this);
    connect(ftp,SIGNAL(getVersionFinished(QString)),SLOT(handGetversionFinished(QString)));
}

void Execute::getVersion()
{
    ftp->isAutoDownloadFolder=false;
    ftp->getVersion();
}
void Execute::handGetversionFinished(QString version)
{
    f->mkinfo(Q_FUNC_INFO,QString("The lasest version num is:%1").arg(version));
    QTextStream out(stdout);
    out<<version;
    std::cout<<version.data();
    std::cout.flush();

// * 我可以在这里获取版本号。     }

在我的客户端程序中,我尝试获取版本号;像这样

void MainWindow::on_checkUpdateAct_triggered()
{
    QString filepath=Paths::currentExeFilePath();
    QStringList args;
    args<<"getversion"<<filepath;
    f->mkinfo(Q_FUNC_INFO,QString("start to check version"));
    connect(&reStartProcess,SIGNAL(readyRead()),SLOT(handUpdateEXEReadyRead()));
    connect(&reStartProcess,SIGNAL(readyReadStandardOutput()),SLOT(handUpdateEXEReadyRead()));
    connect(&reStartProcess,SIGNAL(finished(int,QProcess::ExitStatus)),SLOT(handReStartFinished(int,QProcess::ExitStatus)));
    reStartProcess.start("ClientUpdate.exe",args);
}

void MainWindow::handUpdateEXEReadyRead()
{
    QString version=reStartProcess.readAll();
    reStartProcess.terminate();
    f->mkinfo(Q_FUNC_INFO,QString("The lasest version num is:%1").arg(version));

     if(currentVersion>=version.toFloat())
     {
         f->msg->info("Update Client","Your client is the latest version");
     }
     else
     {
         if(f->msg->ask("Update Client?",QString("The latest version is:%1,Your version is:%2.\nUpdate?").arg(version).arg(currentVersion))==QMessageBox::Yes)
             sendUpdateCommand();
     }

}

但我在handUpdateEXEReadyRead函数中没有得到任何结果,为什么

0 个答案:

没有答案
相关问题