Qml FileDialog on Windows Runtime
Unsolved
QML and Qt Quick
-
I'm developing with Qt 5.5 for WinRT on Windows 10 64bit.
Qml FileDialog can choose files from any directory. But those path can't use from C++ like this.
void QTestView::open(const QString &fileUrl) { QFile file(fileUrl); file.open(QFile::ReadOnly); // fail } FileDialog { id: fdlg modality: Qt.WindowModal title: "Choose a file" selectExisting: true selectMultiple: false selectFolder: false nameFilters: [ "Text files (*.txt)" ] onAccepted: { view.open(fileUrls[0]); } }
Please tell me how to read(or copy to the local directory) a file that selected from FileDialog on Windows Runtime.
-
Thanks! It works well without files on OneDrive. I think that it's an other probrem because StorageFile::CopyAsync fails too.
void copyFile(const QString &fileUrl) { QFileInfo fromFile(QUrl(fileUrl).toLocalFile()); QString toPath = cd.absoluteFilePath(fromFile.fileName()); qDebug() << fromFile.absoluteFilePath() << "->" << toPath; bool res = QFile::copy(fromFile.absoluteFilePath(), toPath); }