Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved onCheckedChanged vs onCheckStateChanged

    General and Desktop
    checkbox
    2
    3
    425
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      chilarai last edited by

      What is the difference between onCheckedChanged and onCheckStateChanged? Both yield the same result when I check/uncheck the box.

      import QtQuick 2.12
      import QtQuick.Controls 2.4
      import QtQuick.Layouts 1.3
      
      Page {
      
          id : somepageid
      
      
          CheckBox {
              checked: true
              text: qsTr("Check Me")
              indicator.width: 15
              indicator.height: 15
      
              onCheckedChanged: {
                  console.log(checked)
              }
      
              onCheckStateChanged: {
                  console.log(checked)
              }
      
          }
      }
      
      KroMignon 1 Reply Last reply Reply Quote 0
      • KroMignon
        KroMignon @chilarai last edited by KroMignon

        @chilarai said in onCheckedChanged vs onCheckStateChanged:

        What is the difference between onCheckedChanged and onCheckStateChanged? Both yield the same result when I check/uncheck the box.

        As written in documentation:

        • checked is a boolean (https://doc.qt.io/qt-5/qml-qtquick-controls2-abstractbutton.html#checked-prop)
        • checkState is an enumeration value Qt.Unchecked, Qt.PartiallyChecked or Qt.Checked (https://doc.qt.io/qt-5/qml-qtquick-controls2-checkbox.html#checkState-prop)

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        C 1 Reply Last reply Reply Quote 2
        • C
          chilarai @KroMignon last edited by

          @KroMignon Thanks

          1 Reply Last reply Reply Quote 0
          • First post
            Last post