C++ – QFile doesn’t recognize file:/// url path format

cqmlqtqtcorequrl

I get the file path from Qml like this:

mainView.projectFilePath = Qt.resolvedUrl(newProjectFileDlg.fileUrl).toString();

The above file path looks like this: file:///C:/uuuu.a3

But when this path is passed to QFile, it complains

The filename, directory name, or volume label syntax is incorrect

How to solve this problem?

Best Answer

QUrl url(newProjectFileDlg.fileUrl);
url.toLocalFile();

This is probably what you need. It will return "C:/uuuu.a3" in your case.