1
我试图读取Qt中的shell脚本的输出。但是,将参数传递给shell脚本不起作用,因为它完全被忽略。以下摘录中我做错了什么?QProcess传递(shell)参数
QProcess *process = new QProcess;
process->start("sh", QStringList() << "-c" << "\"xdotool getactivewindow\"");
process->waitForFinished();
QString output = process->readAllStandardOutput();
target = output.toUInt();
我已经在其他几个线程看上去并试图解决方案,如
process->start("sh", QStringList() << "-c" << "xdotool getactivewindow");
和
process->start("sh", QStringList() << "-c" << "xdotool" << "getactivewindow");
,但没有奏效。
是否'流程 - >启动( “xdotool”,QStringList中()<<“getactivewindow”);'工作?如果你自己在shell中执行它,命令是什么? – m7913d
在shell中,我执行xdotool getactivewindow。和thx,'process-> start(“xdotool”,QStringList()<<“getactivewindow”);'工作!我怀疑是因为只有一个命令没有任何空间可以逃脱。所以原来的问题仍然没有解决。 – Alex