I'm trying to show an QML MessageDialog with Qt 6.4.3. This dialog should be closed with the provided button.
import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
ApplicationWindow {
id: window
width: 800
height: 600
visible: true
title: qsTr("Hello World")
Component.onCompleted: dialog.open()
MessageDialog{
id: dialog
modality: Qt.ApplicationModal
title: "Test Dialog"
text: "My Text"
buttons: MessageDialog.Ok
}
}
PROBLEM: The dialog is dismissed, if the user clickes outside the dialog. I would expect the dialog to stay visible until the user pressed the OK button.
What is my mistake in the following example? How can I achieve, that the dialog stays visible until the user pressed the button?