[Solved] Error while using += operator in Qt


Use QString as primary string type:

QString result = QString("apg -q -n %1 -x %2 -y %3").arg(n).arg(x).arg(y);

Or use a QTextStream to assemble everything.

QString result;
QTextStream ts(&result);
ts << "apg -q -n " << n << " -x " << x;

To use std::string with .arg():

std::string x = "xxx";
QString result = QString("xxx -x %1").arg(x.c_str());

See the Qt documentation for details about QString and QTextStream.

6

solved Error while using += operator in Qt