Get filename without extension
-
How can I get a filename without the extension from a QString?
Thanks. -
i think QFileInfo might help you
Vg
Felix
-
Thanks. I'll try that.
-
What function in QFileInfo will give me the filename without the extension?
-
QFileInfo::baseName
-
I think better QString::remove() should be used. Based either on previously found index of extension begin or on regexp it will be more flexible for further changes.
-
I tried QFileInfo::baseName and it worked perfectly. Thank you for the help.
-
@Denis that cant really be used sometimes i think. If you dont now the extension of the file, its quite ugly to find the extension in a string because of many special cases like differnt length or ".tar.gz" with several "." . So just taking this method save a lot of pain in my opinion
-
QFileInfo does probably exactly what Denis said. However, since someone else did the effort for you, there is absolutely no reason not to use QFileInfo.
1/9