我找到了适合我需要的解决方案。如果我确实提出了一个跨平台的解决方案,我会告诉你们。以下是如何使其在 Linux 环境中的 QT 中工作。
QStringList commands;
commands << "-hold";
commands << "-e";
commands << "ssh username@host 'cd /home/user/backups; mysqldump -u root -p mydb > mydb.sql; echo DONE!'";
QProcess *process = new QProcess(0);
process->setProcessChannelMode(QProcess::MergedChannels);
process->start("xterm", commands);
if(!process->waitForStarted()){
qDebug() << "Could not wait to start...";
}
if(!process->waitForFinished()) {
qDebug() << "Could not wait to finish...";
}
process->closeWriteChannel();
qDebug() << process->readAll();