QT C 上的 QProcess 备份数据库++
我想在QT程序中使用qprocess备份我的数据库,代码如下,但是备份时出现0kb,当我查看错误Qprocess: Destroyed while process("mysqldump.exe") is still running时。
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();
}
你能帮助我吗?我不明白这个错误并确定备份文件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的程序在进程完成之前终止,您需要使用
static bool QProcess::startDetached(program,arguments,workingDirectory)
或添加dump.waitForFinished();
到末尾。另外,您不需要添加“>”到争论。您已使用
dump.setStandardOutputFile(path)
, ">" 重定向输出不适用于进程,因为它需要 shell 来执行命令,QProcess
不使用 shell,它只运行一个进程而不是 shell 表达式。Your program terminates before process finished, you need to either use
static bool QProcess::startDetached(program, arguments, workingDirectory)
or adddump.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.