我想在QT程式中用qprocess備份我的資料庫,代碼如下,但是備份時出現0kb,當我查看錯誤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();
}
你能幫幫我嗎?我不明白這個錯誤和 okb 備份檔案。
uj5u.com熱心網友回復:
您的程式在行程完成之前終止,您需要使用static bool QProcess::startDetached(program, arguments, workingDirectory)或添加dump.waitForFinished();到末尾。
此外,您不需要在引數中添加“>”。您已經使用 , ">" 重定向了輸出dump.setStandardOutputFile(path),它不適用于行程,因為它需要 shell 來執行命令,QProcess不使用 shell,它只運行一個行程而不是 shell 運算式。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/448155.html
下一篇:Qt中如何鏈接庫?
