Lets say I have a list of N arguments which I want to pass to a QString. The number N is variable and determined at runtime.
If I do this:
QString myString = "Some text %1, some other text %2,..., some more text %n"
for(auto arg : list) {
myString = myString.arg(arg);
}
I create a lot of string copies, as I can only change one .arg at a time, and need to save one copy of the string in each iteration. Is there a more efficient way? I looked into the documentation for something like QString::args(SomethingIteratable), but found nothing.
With some hard-coded limit (to transform runtime vector size to compile time one), you might use
arg()overload taking severalQStringAnd then,
visit:Notice than
argin one pass might behave differently than multipass, especially if your inserted texts contain%1.