Maybe try
bool check = r.rename("temp.txt", newpath);
I see you have a QString
called newpath
that is not used in the rename call but you pass newname
which you've appended to newpath
just in the previous line. From code you've posted looks like your just giving a new name and hence why the result file is in the same folder as the original but did get renamed.
Do remember that even with giving a full path QDir::rename will fail if source and destination path's are not on the same partition or for a few more reasons as mentioned in the documentation.