c++ - 简单的QProcess

  显示原文与译文双语对照的内容
0 0

我正在尝试运行一个简单的QProcess,这是我的基本代码。

QDir("/home/brett/sweetback");
 QProcess process;
 process.start("mysqldump -uroot -ppass sweetassurfwear> sweetassurfwear.sql");
 process.waitForFinished(-1);

这怎么了? 我有chaged的密码

QString program ="/usr/bin/mysqldump";
QStringList arguments;
arguments <<"-uroot";
arguments <<"-ppass";
arguments <<"--routines";
arguments <<"sweetassurfwear> sweetassurfwear.sql";
//All the other arguments
QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);

我现在得到错误

sweetgui2.cpp: In member function ‘void SweetGuiForm::on_buttonBox_accepted()’:
sweetgui2.cpp:88: error: no matching function for call to ‘QProcess::QProcess(<unresolved overloaded function type>)’
/usr/include/QtCore/qprocess.h:219: note: candidates are: QProcess::QProcess(const QProcess&)
/usr/include/QtCore/qprocess.h:129: note: QProcess::QProcess(QObject*)
make: *** [sweetgui2.o] Error 1

我已经换了线

QProcess *myProcess = new QProcess(parent);
to
QProcess *myProcess = new QProcess(this);

它现在编译但我仍然没有得到转储文件

时间:原作者:3个回答

0 0

更改以下行:

arguments <<"sweetassurfwear> sweetassurfwear.sql";

到:

arguments <<"sweetassurfwear" <<">" <<"sweetassurfwear.sql";

你需要将不同的字符串作为单独的参数处理。

原作者:
0 0

根据Qt文档,你应该执行类似的操作:

QString program ="PathTo/mysqldump";
QStringList arguments;
arguments <<"-uroot";
arguments <<"-ppass";
//All the other arguments
QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);

注意你应该给应用程序的命令行 参数的方式。

原作者:
...