QML: MessageDialog, organizing standard buttons and setting a default button

I have the following code in my main.qml

 MessageDialog {
    id: exitDialog
    title: "Quit"
    text: "Save before quitting?"
    icon: StandardIcon.Question
    standardButtons: StandardButton.Save| StandardButton.Discard |  StandardButton.Cancel
    onAccepted: {
    ...
    }
    onDiscard: Qt.quit()
}

However, the problem is that the buttons look closed to me without saving Cancel and last Save! The "Default" button is set as closed, without saving. I want my button order in the code to be supported, and also set to save by default. Does anyone encounter such problems? any suggestions?

I saw this answer. How to set the default MessageDialog button in QML? but how to do it for standard buttons?

+4
source share
1

, . http://doc.qt.io/qt-5/qmessagebox.html

. , Windows "" "", Mac OS .

.

QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
0

Source: https://habr.com/ru/post/1649370/


All Articles