At https://api.kde.org/frameworks/kdelibs4support/html/classKUrl.html#a04479511596e499f4f7ffa6acdc96cb3 there is documentated Deprecated: since 5.0, use QUrl::path(). .... This advice results into code returning an invalid path on Windows in case QUrl contains a local path because QUrl::path() on Windows always adds a '/' in front of the path. The following example shows the issue QUrl b = QUrl::fromLocalFile("/test/test.xyz"); qDebug() << b << b.path() << b.toLocalFile(); b = QUrl::fromLocalFile("c:/test/test.xyz"); qDebug() << b << b.path() << b.toLocalFile(); b = QUrl::fromLocalFile("c:\\test\\test.xyz"); qDebug() << b << b.path() << b.toLocalFile() Compiling and running this on Windows (I used Qt 5.5) returns QUrl("file:///test/test.xyz") "/test/test.xyz" "/test/test.xyz" QUrl("file:///c:/test/test.xyz") "/c:/test/test.xyz" "c:/test/test.xyz" QUrl("file:///c:/test/test.xyz") "/c:/test/test.xyz" "c:/test/test.xyz" The second column in line 2 and 3 shows the issue. Because KUrl::path() deals with this case by checking the "local file case" and using toLocalFile() instead porting to QUrl::path() directly will fail therefore. Also the hint to use url.adjusted(QUrl::StripTrailingSlash).path() in case the option RemoveTrailingSlash has been used does not help here. There should be a related hint into the documentation.
https://git.reviewboard.kde.org/r/130177/
Git commit 95a3a5c54518168d5b6ef38a7698b0cf6cdc647b by Ralf Habacker. Committed on 14/07/2017 at 11:19. Pushed by habacker into branch 'master'. Fix 'Deprecated hint for KUrl::path() is wrong on Windows' REVIEW:130177 FIXED-IN:5.37 M +4 -2 src/kdecore/kurl.h https://commits.kde.org/kdelibs4support/95a3a5c54518168d5b6ef38a7698b0cf6cdc647b