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. Strange behavior of qtdesktopcomponents Checkbox
Forum Updated to NodeBB v4.3 + New Features

Strange behavior of qtdesktopcomponents Checkbox

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.8k Views 1 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.
  • H Offline
    H Offline
    HighwayStar
    wrote on last edited by
    #1

    I'm trying to map checked property of checkbox to something else, in example it's mapped to another checkbox. Everything works eas expected (checked property changes on changing mapping property) until I touch checkbox by mouse. After clicing checkbox it will never react to change of its checked property.

    I need it for represent a bool Q_PROPERTY that can be changed by qml GUI either inside C++ app.

    @import QtQuick 1.1
    import QtDesktop 0.1

    ButtonColumn {
    exclusive: false
    CheckBox {
    id: checkbox1;
    text: "Checkbox 1";
    checked: checkbox2.checked;
    }

      Label {
       text: "checkbox1 checked: " + checkbox1.checked;
      }
      
      CheckBox {
       id: checkbox2;
       text: "Checkbox 2";
       checked: checkbox1.checked;
      }
      
      Label {
       text: "checkbox2 checked: " + checkbox2.checked;
      }
    

    }@

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      I've got no experience in desktop components, but it might well be that when you click on the CB, it sets "checked" to a concrete value, breaking the bond between them (that is, the value changes to, for example, "true", instead of "checkbox2.checked"). Try handling the connection in onCheckedChanged slot - there is should work.

      (Z(:^

      1 Reply Last reply
      0
      • H Offline
        H Offline
        HighwayStar
        wrote on last edited by
        #3

        Yes this code works
        @import QtQuick 1.1
        import QtDesktop 0.1

        ButtonColumn {
        exclusive: false
        CheckBox {
        id: checkbox1;
        text: "Checkbox 1";
        checked: checkbox2.checked;
        onCheckedChanged: {
        checkbox2.checked = checked;
        checked: checkbox2.checked;
        }
        }

          Label {
           text: "checkbox1 checked: " + checkbox1.checked;
          }
         
          CheckBox {
           id: checkbox2;
           text: "Checkbox 2";
           checked: checkbox1.checked;
           onCheckedChanged: {
        

        checkbox1.checked = checked;
        checked: checkbox1.checked;
        }
        }

          Label {
           text: "checkbox2 checked: " + checkbox2.checked;
          }
        

        }
        @

        But I still have problem with binding property to C++ Q_PROPERTY, it wont work same manner

        1 Reply Last reply
        0

        • Login

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