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. Bindings not updating when property notify signal is emitted
Forum Updated to NodeBB v4.3 + New Features

Bindings not updating when property notify signal is emitted

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 542 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.
  • P Offline
    P Offline
    patrickkidd
    wrote on last edited by
    #1

    I have a situation where a property binding is not updating when the appropriate C++ property notify signal is changed, despite a Connections object responding to the signal properly. For example:

    TextEdit {
        id: descriptionEdit
    
        // `enabled` never changes
        enabled: eventModel.numDescriptionWritable > 0
    
        // But this one works. What gives?
        Connections {
            onNumDescriptionWritableChanged {
                print('numDescriptionWritableChanged():', eventModel.numDescriptionWritable)
            }
        }
    }
    

    What sort of conditions would make the possible?

    https://alaskafamilysystems.com/

    J.HilkJ 1 Reply Last reply
    0
    • P patrickkidd

      I have a situation where a property binding is not updating when the appropriate C++ property notify signal is changed, despite a Connections object responding to the signal properly. For example:

      TextEdit {
          id: descriptionEdit
      
          // `enabled` never changes
          enabled: eventModel.numDescriptionWritable > 0
      
          // But this one works. What gives?
          Connections {
              onNumDescriptionWritableChanged {
                  print('numDescriptionWritableChanged():', eventModel.numDescriptionWritable)
              }
          }
      }
      

      What sort of conditions would make the possible?

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @patrickkidd

      have you tried with parentheses ?

      enabled: (eventModel.numDescriptionWritable > 0 )

      and do you assign anywhere a bool to enabled, using = ? If yes, than that breaks all previous bindings.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      P 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        hi @patrickkidd

        have you tried with parentheses ?

        enabled: (eventModel.numDescriptionWritable > 0 )

        and do you assign anywhere a bool to enabled, using = ? If yes, than that breaks all previous bindings.

        P Offline
        P Offline
        patrickkidd
        wrote on last edited by
        #3

        @J.Hilk said in Bindings not updating when property notify signal is emitted:

        hi @patrickkidd

        have you tried with parentheses ?

        enabled: (eventModel.numDescriptionWritable > 0 )

        and do you assign anywhere a bool to enabled, using = ? If yes, than that breaks all previous bindings.

        Nope, haven't assigned bool anywhere else. Parenthesis doesn't seem to work.

        https://alaskafamilysystems.com/

        J.HilkJ 1 Reply Last reply
        0
        • P patrickkidd

          @J.Hilk said in Bindings not updating when property notify signal is emitted:

          hi @patrickkidd

          have you tried with parentheses ?

          enabled: (eventModel.numDescriptionWritable > 0 )

          and do you assign anywhere a bool to enabled, using = ? If yes, than that breaks all previous bindings.

          Nope, haven't assigned bool anywhere else. Parenthesis doesn't seem to work.

          J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @patrickkidd
          particular ...

          what does the console log print here ?

          TextEdit {
              id: descriptionEdit
          
              // `enabled` never changes
              enabled: eventModel.numDescriptionWritable > 0
              Component.onCompleted: console.log("descriptionEdit completed", eventModel.numDescriptionWritable, enabled)
          
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          P 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @patrickkidd
            particular ...

            what does the console log print here ?

            TextEdit {
                id: descriptionEdit
            
                // `enabled` never changes
                enabled: eventModel.numDescriptionWritable > 0
                Component.onCompleted: console.log("descriptionEdit completed", eventModel.numDescriptionWritable, enabled)
            
            
            P Offline
            P Offline
            patrickkidd
            wrote on last edited by
            #5

            @J.Hilk said in Bindings not updating when property notify signal is emitted:

            @patrickkidd
            particular ...

            what does the console log print here ?

            TextEdit {
                id: descriptionEdit
            
                // `enabled` never changes
                enabled: eventModel.numDescriptionWritable > 0
                Component.onCompleted: console.log("descriptionEdit completed", eventModel.numDescriptionWritable, enabled)
            
            

            It prints 0 and false, which are the correct values before the model is initialized and before the integer becomes nonzero. Though I think the Connections object is already accomplishing the purpose of that print statement. Therefore, setting ‘enabled’ explicitly from the connections object is a workout that works, though I’d like to fix the problem itself.

            https://alaskafamilysystems.com/

            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