我在尝试通过QProcess启动firefox时遇到问题。 这是我用来启动命令的函数(例如firefox,mkdir,...)
double launch_nowait(string cmd, bool display) {
string command_name = "";
string command_param = "";
bool first_space = false;
for (int p = 0; p < cmd.size(); p++) {
if (!first_space && cmd[p] == ' ') first_space = true;
else {
if (!first_space) command_name += cmd[p];
else command_param += cmd[p];
}
}
cout << "NOWAIT [" << command_name << "][" << command_param << "]" << endl;
QProcess* process;
//process->setWorkingDirectory(".");
//process->waitForFinished();
process->start(QString::fromStdString(command_name), QStringList() << QString::fromStdString(command_param));
return 0;
}
我试过了几件事,比如:
但它始终以段错误结束。
奇怪的是,当我使用此函数创建目录时,它可以正常工作。
感谢您的帮助,