3

The default button is "Yes", but I want to set the button "No" as the default button.

How to do it?

Jeff
  • 111
  • 2
  • 9

1 Answers1

4

I don't see any way to achieve this through the current MessageDialog API, but I'd also imagine that this is very much platform-specific, and that's why it's hidden.

You can make your own dialog, though:

import QtQuick 2.3
import QtQuick.Window 2.0
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2

Window {
    width: 500
    height: 500
    visible: true

    Dialog {
        id: dialog
        visible: true

        contentItem: FocusScope {
            Row {
                anchors.bottom: parent.bottom
                anchors.right: parent.right

                Button {
                    text: "No"
                    isDefault: true
                    focus: true
                    onClicked: dialog.close()
                }
                Button {
                    text: "Yes"
                }
            }
        }
    }
}

dialog

Mitch
  • 23,716
  • 9
  • 83
  • 122
  • Thank you for stopping me going on looking for the solution. I have spent so much time on it. – Jeff Apr 30 '15 at 07:45