[solved] Condition in QString .arg() ?
-
Is it possible to place a condition inside .arg() of a QString.
e.g. something like this :
@ QString hello = QString("hello %1, how are you")
.arg( ?cond? );?cond? : if (TRUE) { return "Joe" } else { return "Harry" } qDebug() << hello;@
-
@ QString hello = QString("hello %1, how are you") .arg((TRUE)?QStringLiteral("Joe"):QStringLiteral("Harry"));@
Like that?
-
Yes, exectly , thank you !
-
bq. QStringLiteral is a new macro introduced in Qt 5 to create ...
error: 'QStringLiteral' was not declared in this scope
seems not available in Qt 4.8.1 (?)
-
Hi,
You can use QLatin1String in case of Qt 4.8
-
yes,
the condition was my main problem and this i learned now :)