Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-70451

DialogButtonBox to order buttons as defined when absent of buttonRole

    XMLWordPrintable

Details

    • Linux/X11, Windows
    • 5135bec50762955b3a1138ecda10214a9d0bf62a (qt/qtquickcontrols2/5.12)

    Description

      I'd like to be able to use DialogButtonBox for its styling, but without using the functionality to automatically order buttons based on the platform. I tried adding buttons without providing DialogButtonBox.buttonRole and hoped that it would show my custom buttons in the order I specify. However, it orders the buttons randomly.

      I peeked at the Qt source and it seems that it's ordering by the memory address of the QQuickAbstractButtons.

      Here is a QML document that shows the random ordering:

      import QtQuick 2.9
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.2
      
      Window {
          id: root
          visible: true
          width: 640
          height: 480
      
          Component {
              id: myComponent
              Dialog {
                  width: parent.width * .9
                  footer: DialogButtonBox {
                      Button { text: "A" }
                      Button { text: "B" }
                      Button { text: "C" }
                  }
              }
          }
          property var thing: null
      
          SequentialAnimation {
              running: true
              loops: Animation.Infinite
              ScriptAction { script: {
                      thing = myComponent.createObject(root)
                      thing.open()
                  }}
              PauseAnimation { duration: 500}
              ScriptAction { script: thing.destroy() }
              PauseAnimation { duration: 100}
          }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mitch_curtis Mitch Curtis
            netcatkate Sarah K
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes