0
votes

The below code worked before, but is not working anymore, to me, for unknown reasons:

import QtQuick 2.2
import QtQuick.Dialogs 1.0

FileDialog {
    id: fileDialog
    title: ""
    folder: "file:///home"
    signal file_opened(var filename)
    onAccepted: {
        file_opened(fileDialog.fileUrls)
        fileDialog.close()
    }
    Component.onCompleted: visible = true
}

I was using shortcuts.home but that also stopped working. Is there anything inherently wrong with the above?

1
You don't need to close the dialog in onAccepted, it calls its own close function while accepting.xeco
What's not working exactly? can't reproduce the issue .. try to delete build folder and rebuildMohammad Kanan
Connecting to file_opened was the issue. I had to create a parent item and put the signal there and have the filedialog call it onAccepted.bardao

1 Answers

-1
votes

You need to open the dialog:

Component.onCompleted: open()

And remove the close() call as mentioned by other answers.