I want to backup my database with qprocess in QT program, the code is as follows, but 0kb occurs when backing up and when I look at the error Qprocess: Destroyed while process("mysqldump.exe") is still runnuing.
QProcess dump(this);
QStringlist args;
QString path="C:/Users/mahmut/Desktop/dbbackupfile/deneme.sql";
args<<"-uroot"<<"-proot"<<"kopuz"<<">";
dump.setStandardOutputFile(path);
dump.start("mysqldump.exe",args);
if(!dump.waitForStarted(1000))
{
qDebug()<<dump.errorString();
}
Can you help to me? ı do not understand this error and okb back up file.
CodePudding user response:
Your program terminates before process finished, you need to either use static bool QProcess::startDetached(program, arguments, workingDirectory)
or add dump.waitForFinished();
to the end.
Also, you dont need to add ">" to arguments. You already redirected output with dump.setStandardOutputFile(path)
, ">" does not work with process as it requires shell to execute command, QProcess
does not use shell it just runs one process not shell expression.