First of all, jacek is right when he points to the risk of injection attacks.
So building an sql query directly with input from user data is potentially dangerous.
However, if you don't care or if it does not apply to you, I like the following way to build complicated strings:
queryStream
<< "INSERT INTO comm_records (caller_id, userID) VALUES ('"
<< number << "','"
<< userID << "');";
QString queryString;
QTextStream queryStream(&queryString);
queryStream
<< "INSERT INTO comm_records (caller_id, userID) VALUES ('"
<< number << "','"
<< userID << "');";
To copy to clipboard, switch view to plain text mode
Afterwards you find your desired statement in queryString.
Bookmarks