Results 1 to 3 of 3

Thread: Strange binding error in Flow element

  1. #1
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Question Strange binding error in Flow element

    Hi,

    I receive a strange binding error that I don't understand. The output seems to work as expected. By commenting out unnessecary stuff I've tracked it down to this minimal example:

    Qt Code:
    1. Flow {
    2. height: visible ? childrenRect.height : 0
    3. Repeater {
    4. model: [my model]
    5. delegate: CheckBox {
    6. }
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    That gives me
    QML Flow: Binding loop detected for property "height"
    Please note: if I change height property to
    Qt Code:
    1. height: childrenRect.height
    To copy to clipboard, switch view to plain text mode 
    (thus removing the ternary operator), the error does not occur. That especially leaves me puzzled.

    Any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,710
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Strange binding error in Flow element

    Its seems that you have, just as the error states, a recursive property binding.
    That means, that one height property effects the other, and the other is bound to the first, causing an infinite loop of setting values between the to height properties.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    sedi (2nd May 2017)

  4. #3
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Lightbulb Re: Strange binding error in Flow element

    I don't know how this can be a binding error, but of course you are right. Actually, the solution is quite simple after all: I define a bool property in the parent item and let both visible and height reference to it:
    Qt Code:
    1. property bool flowVisible: true
    2. Flow {
    3. visible: flowVisible
    4. height: flowVisible? childrenRect.height : 0
    5. Repeater {
    6. model: [my model]
    7. delegate: CheckBox {
    8. }
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    Thanks!

Similar Threads

  1. Replies: 1
    Last Post: 30th November 2013, 11:03
  2. Replies: 9
    Last Post: 23rd April 2012, 13:53
  3. Strange Error
    By keeperofthegrove in forum Newbie
    Replies: 4
    Last Post: 22nd October 2008, 14:16
  4. strange QT error out of nowhere
    By Penut in forum Qt Programming
    Replies: 5
    Last Post: 14th August 2008, 01:46
  5. Strange error
    By joseph in forum General Programming
    Replies: 3
    Last Post: 8th February 2008, 13:32

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.