Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to inspect binding on property?
Forum Updated to NodeBB v4.3 + New Features

How to inspect binding on property?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 287 Views 2 Watching
  • 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.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1

    I am using RadioButton items and I am confused as to why my bindings to the checked property are not being broken when I click the buttons. This test program lets me test this out but check if the bindings are still working. If I click any of these RadioButtons I would expect the binding to break. But when enabling the timer (which activates a cycle to test the bindings) it acts as if the binding is working. Very confused.

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Controls 2.15
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Property Binding Test")
    
        Rectangle {
            anchors.fill: column1
            color: "lightblue"
        }
    
        Column {
            id: column1
    
            property int radioValue: 0
    
            RadioButton {
                id: rad1
    
                checked: column1.radioValue === 0
    
                onClicked: column1.radioValue = 0
            }
            RadioButton {
                id: rad2
    
                checked: column1.radioValue === 1
    
                onClicked: column1.radioValue = 1
            }
            RadioButton {
                id: rad3
    
                checked: column1.radioValue === 2
    
                onClicked: column1.radioValue = 2
            }
            RadioButton {
                id: rad4
    
                checked: column1.radioValue === 3
    
                onClicked: column1.radioValue = 3
            }
        }
    
        Timer {
            running: checkbox.checked
            interval: 500
            repeat: true
    
            onTriggered: {
                let tmp = column1.radioValue
                tmp += 1
                if(tmp >= 4){
                    tmp = 0
                }
                column1.radioValue = tmp
    
                for(let cnt=0; cnt < column1.children.length; ++cnt){
                    console.log(column1.children[cnt].checked)
                }
            }
        }
    
        CheckBox {
            id: checkbox
    
            anchors.top: column1.bottom
    
            text: "Run"
        }
    }
    

    C++ is a perfectly valid school of magic.

    A 1 Reply Last reply
    0
    • fcarneyF fcarney

      I am using RadioButton items and I am confused as to why my bindings to the checked property are not being broken when I click the buttons. This test program lets me test this out but check if the bindings are still working. If I click any of these RadioButtons I would expect the binding to break. But when enabling the timer (which activates a cycle to test the bindings) it acts as if the binding is working. Very confused.

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Property Binding Test")
      
          Rectangle {
              anchors.fill: column1
              color: "lightblue"
          }
      
          Column {
              id: column1
      
              property int radioValue: 0
      
              RadioButton {
                  id: rad1
      
                  checked: column1.radioValue === 0
      
                  onClicked: column1.radioValue = 0
              }
              RadioButton {
                  id: rad2
      
                  checked: column1.radioValue === 1
      
                  onClicked: column1.radioValue = 1
              }
              RadioButton {
                  id: rad3
      
                  checked: column1.radioValue === 2
      
                  onClicked: column1.radioValue = 2
              }
              RadioButton {
                  id: rad4
      
                  checked: column1.radioValue === 3
      
                  onClicked: column1.radioValue = 3
              }
          }
      
          Timer {
              running: checkbox.checked
              interval: 500
              repeat: true
      
              onTriggered: {
                  let tmp = column1.radioValue
                  tmp += 1
                  if(tmp >= 4){
                      tmp = 0
                  }
                  column1.radioValue = tmp
      
                  for(let cnt=0; cnt < column1.children.length; ++cnt){
                      console.log(column1.children[cnt].checked)
                  }
              }
          }
      
          CheckBox {
              id: checkbox
      
              anchors.top: column1.bottom
      
              text: "Run"
          }
      }
      
      A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      @fcarney
      It looks like you can inspect bindings using KDAB's GammaRay

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved