Files
qt6-qml-for-beginners/Qt6QMLBeginnersCode/9-Dialogs/3-FileDialog/Main.qml
2025-09-28 17:05:51 +08:00

71 lines
1009 B
QML

// Copyright (c) Daniel Gakwaya.
// SPDX-License-Identifier: MIT
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Dialogs
Window {
visible: true
width: 640
height: 480
title: qsTr("FileDialog")
Column {
spacing: 20
anchors.centerIn: parent
Button{
text: "Choose File"
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
fileDialogId.open()
}
}
Text {
id: textId
text: "Use hasn't chosen yet"
wrapMode: Text.Wrap
}
FileDialog{
id: fileDialogId
title: "Choose File"
nameFilters: ["Text files (*.txt)", "HTML files (*.html *.htm)", "Images (*.jpg *.png)"]
onAccepted: {
textId.text = selectedFile
}
onRejected: {
textId.text = "Dialog rejected"
}
}
}
}