[solved] Condition in QString .arg() ?
General and Desktop
6
Posts
3
Posters
1.5k
Views
1
Watching
-
wrote on 24 Feb 2014, 09:33 last edited by
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;@
-
wrote on 24 Feb 2014, 09:37 last edited by
@ QString hello = QString("hello %1, how are you") .arg((TRUE)?QStringLiteral("Joe"):QStringLiteral("Harry"));@
Like that?
-
wrote on 24 Feb 2014, 09:52 last edited by
Yes, exectly , thank you !
-
wrote on 24 Feb 2014, 10:23 last edited by
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
-
wrote on 24 Feb 2014, 10:31 last edited by
yes,
the condition was my main problem and this i learned now :)
1/6