Reputation: 495
I am using Qt 4.7.4. I have a relative file path that I am storing as a QString and I want to later convert it into an absolute file path. However, when I create a QFileInfo object from that QString and call absoluteFilePath(), the path is still not absolute. For example:
QString fn = "..\..\..\..\..\..\App\exampledata\doll\everything-F.wrl";
QFileInfo fi(fn);
QString fn2 = fi.absoluteFilePath();
And now fn2 contains "C:/../../../App/exampledata/doll/everything-F.wrl", while I want it to contain "C:/App/exampledata/doll/everything-F.wrl". I could manually remove the useless dots, but that's tedious.
Upvotes: 3
Views: 3133
Reputation: 206929
That's not the function you should be calling if you want a canonical path. You should be using QFileInfo::canonicalFilePath
instead.
Upvotes: 6