[英]How to get INT variable to QProcess write command?
Following code works以下代码有效
QProcess *p = new QProcess();
p->write("10 cats\n");
Now I need to send int
variable to write
command.现在我需要发送int
变量来write
命令。
Something like:就像是:
QProcess *p = new QProcess();
int i = 10;
p->write(i << " cats\n");
Looks like you want to append variables to then pass them as parameter.看起来您想附加变量然后将它们作为参数传递。
try something like this尝试这样的事情
int i{10};
QString formattedString{QString("%1 cats\n").arg(i)};
QProcess* p = new QProcess();
p->write(formattedString.toStdString().c_str());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.