I am doing an App in QML / QT / C++ (to train myself for an internship). I need to open a FileDialog
in order to choose a folder location but I get an error when writing the line selectFolder: true
.
I found this property here https://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html#selectFolder-prop
It's weird because I can't set selectExisting
and selectMultiple
either.
The documentation said we have to specify these before opening the Dialog. I did this, I don't understand.
Can anyone help me fix this error ?
Here is what I import in main.qml: import QtQuick.Dialogs 1.3
Thank you very much. Have a good day.
Here is the code:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Dialogs 1.3
Window {
id: mainWindow
visible: true
width: 700
height: 500
// FileDialog
FileDialog {
id: fileDialog
title: "Please choose a file"
folder: shortcuts.home
selectFolder: true
onAccepted: {
console.log("You chose: " + fileDialog.fileUrls)
//acceptDialog();
}
onRejected: {
console.log("rejected")
//rejectDialog();
}
Component.onCompleted: visible = true
}
}
It's not the entire code (+ 200 lines) Image from Qt Creator