Qt - App crashes when FileDialog is opened

127 views Asked by At

I pulled the file dialog code directly from the Qt6 FileDialog Man Page. When I click the button, the file dialog flashes briefly, then I often get the "this program would like to access your documents folder" dialog from MacOS, and then the app crashes.

Specs: MacOS Ventura 13.5 Macbook M1 chip Qt 6.5.1 (from Homebrew)

Commenting out the FileDialog.currentFolder line does not fix the issue.

I first tried the qt.labs version of the FileDialog, that crashed in the exact same way.

import QtCore
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Dialogs

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    Rectangle {
        id: page
        width: parent.width
        height: parent.height
        color: "lightgray"

            Button {
                text: qsTr("Select File")
                onClicked: fileDialog.open()
            }

            Image {
                id: image
                anchors.fill: parent
                fillMode: Image.PreserveAspectFit
            }

            FileDialog {
                id: fileDialog
                currentFolder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
                onAccepted: image.source = selectedFile
            }

        }
    }
}

There is a similiar issue from 4 months ago where the asker did not give all the system info or answer all the comments, and no solution was proposed. I tried my best to give all info here.

0

There are 0 answers