[SOLVED] String formating %1%2 vs %2%1
-
Saugglocke & Salvatello
I understand what you want to say. And I solved my issues before I started to write this thread. I've just reordered the args as they appear in the string. I could solve it using sprintf the same way. For me is also easier to format the output with sprintf as it is easier and more logical.The second form of Salvatello is not wrong. In my opinion the library works wrong.
I just wanted to check and put forward that the whole concept no matter where it appears falls as it can't be used as described. I can't really rely that the transtlatted string will work as expected.
-
I see what you're saying but I don't see how every separate call to .arg() with the single parameter could consider the case of the string replacement you describe here (the creation of & for example, which really reads as the 26th argument).
Maybe what you should have done (or did already) is use the overload that replaces the strings in one pass?
http://qt-project.org/doc/qt-5/qstring.html#arg-2
@
QString QString::arg(const QString & a1, const QString & a2) const
@bq. This is the same as str.arg(a1).arg(a2), except that the strings a1 and a2 are replaced in one pass. This can make a difference if a1 contains e.g. %1
Anyway, if you got to this or another solution, please post it and edit the post title to [SOLVED].
-
Hi Frankie,
I have not. But seems the only way to make it work correctly.