Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved MessageDialog has no states: property?

    QML and Qt Quick
    qml property states
    2
    3
    1222
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      ars1614 last edited by

      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.

      Thanks!

      ? 1 Reply Last reply Reply Quote 0
      • ?
        A Former User @ars1614 last edited by A Former User

        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.

        A 1 Reply Last reply Reply Quote 2
        • A
          ars1614 @Guest last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post