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

QML button: double click does not emit clicked() but changes checked state

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.15.5
    • Quick: Controls 2
    • None
    • All

    Description

      Why is this a problem? Because it breaks manual bindings for the checked property: Button's code alters the checked state when seemingly no one asked it to. Consider the following code (adapted from plasma-pa applet):

      SmallToolButton {
          id: muteButton
      
          icon.name: Icon.name(item.model.Volume, item.model.Muted, isPlayback)
          text: item.model.Muted ? "Unmute" : "Mute"
      
          onClicked: item.model.Muted = !item.model.Muted;
          checked: item.model.Muted
      }
      

      This component is supposed to manage its checked state externally, since audio sources/sinks may switch their muted state by other means (e.g. Mute key on a keyboard, or via other software). But what happens if a user double clicks it?

      Starting with qtquickcontrols2@09476c590ab13623130d5ac79045fa68e504be96 the clicked() is no more emitted after doubleClicked(), but the nextCheckState() is still called regardless!

      There are two problems at once:

      1. There's no way to disable internal management of the checked property. Setting checkable to false does not help, because it would be immediately reset to true the next time setChecked is called.
      2. Double click triggers checked state change.
      3. Double click is emitted even when there are no listeners. But his is not a problem anymore, since the fix was merged for Qt 6 as qtdeclarative@778e08a4061a87b5b2d6c4cee082ded74e1bcc64

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              ratijas ivan tkachenko
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes