Dialog standardButtons
-
Hello,
I would like to know how to get the result of which button was press.
For example I have yes, no , ok, cancel. If I click on no I know that it is rejected but I don't know if the user press no or cancel.Thank you,
-
Dialog { id: dialog standardButtons: Dialog.Yes | Dialog.No | Dialog.Ok | Dialog.Cancel Connections { target: dialog.footer onClicked: { if (button.text === dialog.standardButton(Dialog.Cancel).text) console.log("Cancel clicked") else if (button.text === dialog.standardButton(Dialog.No).text) console.log("No clicked") } } }
It looks ugly, but it works
-
@Nifiro I am away from my computer at the moment but I believe it is possible to compare
button
directly withstandardButton(Dialog.Cancel)
etc.i.e.
if (button === dialog.standardButton(Dialog.Cancel)) { ...
I seem to recall having to do this inside an explicit
DialogButtonBox
though. I don't seestandardButton()
defined as a method onDialog
, though I am stuck with using 5.9.6 at the moment and maybe it has changed since.Edit: Just looked at more recent doc and I still don't see
standardButton()
defined onDialog
itself, but maybe it is available but undocumented?