Qt 安装程序框架:maintenancetool --checkupdates 标志不返回任何内容

问题描述 投票:0回答:3

与 Qt 应用程序在线安装程序捆绑在一起的维护工具据说可以使用“--checkupdates”标志无头运行,该标志返回更新信息(如果有)(请参阅Qt 安装程序框架:自动更新)。不幸的是,即使有已知的可用更新,我也无法让此命令实际返回任何内容。我可以从命令行启动维护工具并且更新可见,但尝试使用 --checkupdates 标志不会产生任何结果。

QProcess update;
update.setWorkingDirectory(QDir::currentPath());
update.start("maintenancetool --checkupdates");

// Wait until the maintenancetool is finished
update.waitForFinished();

// Read the output
QByteArray data = update.readAllStandardOutput();

如果删除 --checkupdates 标志,我可以获得此代码来打开维护工具,但即使有更新,数据也始终为空。如果我尝试在命令行中运行该进程,它也不会产生任何结果,所以我认为这不是代码的问题。有任何想法吗?好像这方面的资料不多。

qt qt-installer
3个回答
1
投票

虽然我不知道原因,但问题似乎是

--checkupdates
标志不返回任何数据。但是,它确实具有基于是否有可用更新的适当退出代码。我已经重写了我的应用程序以捕获退出代码并相应地启动(或不启动)维护工具。感觉就像黑客,但它确实有效。


0
投票

如果没有可用的更新,维护工具将不返回任何内容。在启动维护工具之前,我将结果发送到文本文件,如下所示:

@echo off
maintenancetool.exe --checkupdates > checkUpdate.txt

findstr /c:"updates" checkUpdate.txt

if %errorlevel% == 0 maintenancetool.exe --script=script.qs

0
投票

我使用以下方法来检查维护工具中的更新。

void QProcess::start(const QString &program, const QStringList &arguments = {},QIODeviceBase::OpenMode 模式 = ReadWrite)

QProcess process;

QStringList args;
args.append("--checkupdates");
args.append("-v");


process.start("maintenancetool",args);
        
// Wait until the update tool is finished
//-1 means the function will not time out, waiting for either error or success
if(process.waitForFinished(-1))
  {
      qDebug() << "Process started";
  }
  else 
  {
      qDebug() << process.error();
  }

 // Read the output
 QByteArray data = process.readAllStandardOutput();
© www.soinside.com 2019 - 2024. All rights reserved.