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

Animate RadioButton in the Material style

    XMLWordPrintable

Details

    • All
    • 872672288 (dev), fa184d038 (6.7), 18159e199 (6.6), 9707caa0e (tqtc/lts-6.5)

    Description

      RadioButton don't have any animation when changing state in the Material style, unlike CheckButton. It should grow when checked and shrink when unchecked. Now that support for Material 3 was added this is the perfect time to fix this.

      I fixed that on my projects by modifying the inner Rectangle of the RadioIndicator source code:

      // Original source for Material's RadioIndicator from Qt 6.5.0
      Rectangle {
          x: (parent.width - width) / 2
          y: (parent.height - height) / 2
          width: 10
          height: 10
          radius: width / 2
          color: parent.border.color
          visible: indicator.control.checked || indicator.control.down
      } 

      I only changed three lines:

      // My source
      Rectangle {
          x: (parent.width - width) / 2
          y: (parent.height - height) / 2
          width: indicator.control.checked ? 10 : 0 // modified, replaces "visible"
          height: width                             // modified
          radius: width / 2
          color: parent.border.color
          Behavior on width { NumberAnimation { easing.type: Easing.OutBack } } // added
      } 

      I know you guys don't like to use Behavior in sources but this is the easier way for me and it works. There's an example of one of my projects bellow. Hope this helps!

      Attachments

        For Gerrit Dashboard: QTBUG-113532
        # Subject Branch Project Status CR V

        Activity

          People

            mitch_curtis Mitch Curtis
            ceperez1996 Carlos Pérez
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes