因此,在我现在的代码中,它可以毫无问题地加载gphoto2并添加--- shell开关。如何添加一行来向该shell发出命令我想要发给shell的命令是" start-preview-stream"再次感谢!
QProcess gphoto2;
gphoto2.start("gphoto2", QStringList() << "--shell");
if (!gphoto2.waitForStarted()){
qDebug("gPhoto2 didn't start properly");
return 1;
}
qDebug("gPhoto2 Started Successfully");
调试显示
gPhoto2 Started Successfully
我也试过以下但没有运气
QProcess gphoto2;
gphoto2.start("gphoto2", QStringList() << "--shell" << "start-preview-stream");
if (!gphoto2.waitForStarted()){
qDebug("gPhoto2 didn't start properly");
return 1;
}
qDebug("gPhoto2 Started Successfully");
答案 0 :(得分:0)
如果您只需要将该字符串发送到流程的标准输入流,则需要write()
到QProcess
:
QProcess gphoto2;
gphoto2.start("gphoto2", QStringList() << "--shell");
if (!gphoto2.waitForStarted()){
qDebug("gPhoto2 didn't start properly");
return 1;
}
qDebug("gPhoto2 Started Successfully");
gphoto2.write("start-preview-stream\n");
(显然,您需要添加一些适当的返回值检查等。)