@davethedave
Firstly, I don't work in C++ so I don't test the code for the right way to pass the output string to printf(). So your corrections are good. [BTW you'd be better off not using printf() and using Qt/C++ functions, then you wouldn't have all that toUtf8().constData() stuff, but that's another matter.]
As you can see you have 3 rows matching the query, you tell us you have 5, or you had 5 and now you have 3. That's worrying when you're asking for help. Your Username value appears to be 1 from the output. That is a strange username. I don't know what your problem is. The original code should correctly print out whatever is in the Username column of each row encountered (note that since you didn't put a \n in it will all come on one line, which isn't great, I do trust that is not what this is all about.)