@Nifiro Minor correction: like me, you're setting the property on OKing the dialog, not on destruction of the FileDialog (which never gets destroyed until the program closes). But you're right, it seems to work.
But I'm doing something a little different in my program: I'm defining the Settings object in my Main.qml, with the id "settings", while the FileDialog is in a different .qml file that is instantiated as a descendent of the main window. So I wrote this little test program, consisting of this Main.qml:
import QtQuick 2.13
import QtQuick.Window 2.13
import Qt.labs.settings 1.0
Window {
id: win
visible: true
width: 100
height: 100
title: qsTr("FileSettingsTest")
Settings {
id: settings
property url myDir
}
Dialog {
anchors.fill: parent
}
}
and this Dialog.qml file:
import QtQuick 2.13
import QtQuick.Dialogs 1.3
Rectangle {
MouseArea {
anchors.fill: parent
onClicked: fileDlg.open()
}
FileDialog {
id: fileDlg
folder: settings.myDir || shortcuts.desktop
onAccepted: {
settings.myDir = folder
close()
}
visible: false
}
}
For some reason this fails, in the manner I described originally.
I thought there might be some problem with the name "settings", so I changed it (in one place in Main.qml and two places in Dialog.qml) to "setngs", and all of a sudden it worked!
So I went back into my much larger program, and changed "settings" to "setngs" in both files. It didn't work!
I'm wondering if my understanding of the visibility of object ids across file boundaries is a little off. But this is really mysterious, because if my Dialog.qml can't refer to settings.myDir, why does it work to write settings.value("myDir")? It's as though something is interfering with my ability to refer to my Settings object sometimes, and I can't figure out when or why.
Could you, or anyone, try my example, and figure out why I can refer to my Settings if I call it "setngs" but not "settings"? Or maybe you understand scope rules better than I do, and can see immediately what I'm doing wrong.