PDA

View Full Version : Using rename in Qfile



jvwlong
23rd July 2012, 21:49
Hello. I am trying to change the name of a file that I SSH over to my local Ubuntu computer from an external linux computer. I am trying to use the Qfile class, but I am confused as to how to use the rename function. I have to make a system that makes sure I don't overwrite the old data. So i need to have a counter that increases and is added tot he name of the file so the file(s) wont ever get overwritten. So how do i use the Qstring class to achieve this. because the rename function calls for it's use and I am pretty lost.

-Thanks

MrShahi
24th July 2012, 06:51
Hi JvwLong,
you can use member function of QFile, i.e bool QFile::rename ( const QString & oldName, const QString & newName ) [static] to rename your file. you can use a static counter and increase or decrease its value as you want. and as well you can convert it into QString using QString::number(int ).
I hope it will helpful to you.
:)