MessageDialog has no states: property?

  • I am trying to use only one MessageDialog for all the applications warnings, errors... Each time I open it, I rewrite everything, but I wondered if there is no such a property like in others controls to do it easier.


  • MessageDialog has no states: property

    That's because dialogs don't inherit from Item. But you can make your own dialog that extends MessageDialog. You can then add your own states property with StateGroup QML Type.

  • @Wieland I have tried what you said and I am having this error: Cannot assign to non-existent default property at line StateGroup.
    This is my code:

    MessageDialog {
            id: msgDialog
            icon: StandardIcon.Warning;
            standardButtons: StandardButton.Ok
            StateGroup {
                id: msgDialogStates
                states: [
                    State {
                        name: "ActionsDialog"
                        PropertyChanges {
                            target: msgDialog
                            title: qsTr("Actions Error")
                            text: qsTr("Message.")
                    }, State {
                        name: "PropertiesDialog"
                        PropertyChanges {
                            target: msgDialog
                            title: qsTr("Properties Error");
                            text: qsTr("Another.")

    The lines with the properties: title, text, icon and standardButtons are in red as I mencioned in another post.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.