I thought that this should have been a super common use case:
import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Controls.Universal 2.15import QtQuick.DialogsDialog { id: rootItem title: qsTr("Save unsaved changes?") standardButtons: Dialog.Yes | Dialog.No | Dialog.Cancel modal: true Component.onCompleted: { visible = false; } onAccepted: { // Unsaved changes accepted } onRejected: { // Unsaved changes rejected }}
How can I make a difference between user clicking on No
and Cancel
? The documentation seems to be very poor on this. Yes
means "accepted" and both No
and Cancel
means "rejected". In my application's state machine I want to know how the user rejected.
https://doc.qt.io/qt-6/qml-qtquick-controls-dialog.html
Dialog.No A "No" button defined with the NoRole.
What NoRole
? What should I do with this undocumented NoRole
?
I feel stupid.