2

Following code works

QProcess *p = new QProcess();
p->write("10 cats\n");

Now I need to send int variable to write command.

Something like:

QProcess *p = new QProcess();
int i = 10;
p->write(i << " cats\n");
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
user9066046
  • 87
  • 1
  • 10

1 Answers1

1

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());
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97