I have a QString
and I'd like to generate a new string with all characters separated. One way would be to iterate manually over the string and insert the separator after each character but the last one.
Is there a better method or at least a more direct one without having to implement the loop? For example, in order to use directly as function parameter. If possible, using Qt only.
const QString s("Hello world!");
const QString r(some_separating_function(s));
qDebug() << r;
The expected output would be
"H-e-l-l-o- -w-o-r-l-d-!"
EDIT: I'm self-answering it since I didn't find a better solution in SO and I find it useful. If anyone has a better solution I'll appreciate it.