Reputation: 31
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
Upvotes: 2
Views: 2336
Reputation: 31
I resolved the problem.
My Qt Project version was 5.12, I created a new project with Qt 5.14 and it worked. Thanks.
Upvotes: 1
Reputation: 304
For me, the code worked fine. Just try to delete and then put the line again. Sometimes qml gives you these kinds of errors for no reason. Just try to run it. If there are some errors, post them
Upvotes: 0