What am i doing wrong with QFile::rename?
Qstring oldName = ("/home/myusername/Desktop/11.txt");
Qstring newName = ("/home/myusername/Desktop/22.txt");
bool QFile::rename ( const QString & oldName, const QString & newName );
Please tell me how to fix it and post the code since i am a new user to qt and coming from basic.net.
[[Moved another thread out of QnA and added code formating, Tobias]]
Seems like the title is different from your goal/link...
This works in windows, just change the oldName and newName to machine-specific uri.
Also, it is only a commandline program.
int main(int argc, char *argv)
QCoreApplication a(argc, argv);
QString oldName = "D:\11.txt";
QString newName = "D:\22.txt";
Note that I used qDebug() to show if the "rename" is successful or not.
QFile::rename() will be only true if "oldName" exists!
I think the problem is that you are declaring twice the same variables. When you call the function with arguments that are existing variables, just use the name.
QFile::rename (oldName, newName );
PD: As somebody told you in another post, you should learn more about C++.