Consider the following Code:
QString path
= "C:\\Development\\releases\\readme.txt";
qDebug() << "Original: " << path;
qDebug
() <<
"As URL: " <<
QUrl::fromLocalFile(path
);
qDebug
() <<
"Result: " <<
QUrl::fromLocalFile(path
).
toLocalFile();
QString path = "C:\\Development\\releases\\readme.txt";
qDebug() << "Original: " << path;
qDebug() << "As URL: " << QUrl::fromLocalFile(path);
qDebug() << "Result: " << QUrl::fromLocalFile(path).toLocalFile();
To copy to clipboard, switch view to plain text mode
Real Output:
Original: "C:\Development\releases\readme.txt"
As URL: QUrl( "file:///C:/Development/releases/readme.txt" )
Result: "C:/Development/releases/readme.txt"
Exspected Output:
Original: "C:\Development\releases\readme.txt"
As URL: QUrl( "file:///C:/Development/releases/readme.txt" )
Result: "C:\Development\releases\readme.txt"
The path separator is not correct after the conversion. For Qt this is ok, because it can handle it, but if the path is used external this is a problem.
Is there a way to get arround this (except for using everytime replace("/", "\\") if a url is converted to a file path)
Bookmarks