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

Allow disabling interaction with controls

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • None
    • Quick: Controls 2
    • None

    Description

      In design studio there is a use case where a CheckBox can be "read-only". The user can't click on it, but they can click on an action indicator to the left of it that opens a menu. Currently the only way to achieve this is to use a MouseArea to block the CheckBox while the "readOnly" property is true. Using Binding to force the checked state doesn't work (you can still affect it by clicking on it):

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      
      ApplicationWindow {
          width: 640
          height: 480
          visible: true
      
          CheckBox {
              id: checkBox
      
              property bool readOnly: true
      
              Binding {
                  target: checkBox
                  property: "checked"
                  value: false
                  when: checkBox.readOnly
              }
      
              Binding {
                  target: checkBox
                  property: "checkState"
                  value: Qt.Unchecked
                  when: checkBox.readOnly
              }
          }
      }
      

      Setting enabled to false is not an option because that then disables the action indicator (which is a child of the CheckBox).

      So we could add an interactive property which disables interaction with the control itself but not its children.

      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
              mitch_curtis Mitch Curtis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes