Seperate Path and File from a QString or a QFile
-
Hello,
As the title says, I want to get the file name out of a FilePath to change the name of the file before saving it.
As a matter of fact, my application has to be runable on all OS so it' s not really possible to play on splitting the QString.I was surprised not to find a way to do it directly in the doc.
Does anyone know how to do it?
Thanks
-
you can use:
@// fileName that contains the full file path name and is a QString type
QFile file(fileName);
if (file.exist()) {
// Message
} else {
// your method
QString name = file.fileName(); // Return only a file name
} @Best regards
-
You can instantiate a "QFileInfo":http://doc.qt.nokia.com/latest/qfileinfo.html with your file passed in constructor. Then you can use a lot of getting functions from QFileInfo.
-
[quote author="cincirin" date="1305814593"]You can instantiate a "QFileInfo":http://doc.qt.nokia.com/latest/qfileinfo.html with your file passed in constructor. Then you can use a lot of getting functions from QFileInfo.[/quote]
That's right... other way to acces to file information.