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

Make it easier to use tri-state CheckBoxes

XMLWordPrintable

    • 960798f9117bc5aa4aa55bf868cbb0286f8e99b6

      A small example that isn't that nice:

      import QtQuick 2.6
      import QtQuick.Controls 2.0
      import QtQuick.Layouts 1.1
      import QtQuick.Window 2.0
      
      Window {
          width: column.implicitWidth
          height: column.implicitHeight
          visible: true
      
          ColumnLayout {
              id: column
              anchors.centerIn: parent
      
              CheckBox {
                  text: qsTr("Languages")
                  checkState: english.checked && norwegian.checked
                      ? Qt.Checked : (english.checked || norwegian.checked) ? Qt.PartiallyChecked : Qt.Unchecked
                  tristate: true
              }
              CheckBox {
                  id: english
                  text: qsTr("English")
                  checked: true
                  leftPadding: indicator.width
              }
              CheckBox {
                  id: norwegian
                  text: qsTr("Norwegian")
                  checked: true
                  leftPadding: indicator.width
              }
          }
      }
      

      Ideally there would be a C++ model where the state is stored, but we'd still need an example that demonstrates how to hook that up to the boxes.

      Some kind of QML convenience API would also help. JP suggested ButtonGroup::checkState, which would in turn require an exclusive property to turn off the exclusivity.

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

            Unassigned Unassigned
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: