Results 1 to 10 of 10

Thread: Eliminate Binding loop warning

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Location
    Veszprém, Hungary
    Posts
    34
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Eliminate Binding loop warning

    Hello,

    I have a sample code listed below. It works well, but always writes a debug message:
    QML QDeclarativeRectangle_QML_0: Binding loop detected for property "parent"

    Do anybode have any idea, how could I eliminate this warning?

    Qt Code:
    1. import QtQuick 1.0
    2.  
    3. Rectangle {
    4. id: rect1
    5. color: "lightblue"
    6. width: 800
    7. height: 600
    8.  
    9. Item {
    10. width: 600
    11. height: 600
    12.  
    13. Rectangle {
    14. id: test
    15. parent: getRootObject()
    16. anchors.fill: parent
    17. color: "yellow"
    18. opacity: 0.5
    19.  
    20. //! goes to the root object via the item's parent property
    21. function getRootObject() {
    22. var item = test.parent
    23. while (item.parent != undefined) {
    24. item = item.parent
    25. //console.log("w: "+ item.width + " h: " + item.height)
    26. }
    27. return item
    28. }
    29. }
    30. }
    31. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Eliminate Binding loop warning

    What's the point of what you are trying to do? Why not simply declare the object with a proper parent in the first place?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Location
    Veszprém, Hungary
    Posts
    34
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Eliminate Binding loop warning

    It's a MessageBox component. I have to fill the screen with a MouseArea to 'eat' the mouse click events.
    There is a controller logic in QML which loads different QML files. But I want an universal messagebox, and not always really know, 'who' is the root object, that's why I wanted to use this approach.
    Maybe I can solve simply returning from the C++ side a pointer of the rootObject, but I wanted to keep it in the QML side.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Eliminate Binding loop warning

    You can keep it in QML. Create the component on the fly when you need it and just put it on top of everything, you don't need to reparent it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2010
    Location
    Veszprém, Hungary
    Posts
    34
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Eliminate Binding loop warning

    Do You have a sample how do you think? If I not reparent the item, then positioning will be strange. For example I have an info and a task bar at the upper and the lower parts of the screen. If I don't reparent the item and set x and y to 200, it will be relative to the parent item - the upper side of the screen or the lower. Or not?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Eliminate Binding loop warning

    If you create the item parentless, it will be working in scene (aka absolute) coordinates. Or you can declare it as a child of your root element and work in this element's coordinates.

    However wouldn't it be simpler to make your message box modal simply by disabling all other mouse areas? You can do that with one property binding.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    laszlo.gosztola (17th August 2011)

Similar Threads

  1. Replies: 10
    Last Post: 15th August 2011, 18:33
  2. Replies: 4
    Last Post: 6th August 2011, 01:40
  3. Replies: 5
    Last Post: 16th February 2011, 08:33
  4. Resizing QTableView to eliminate horizontal scroll bar?
    By russford in forum Qt Programming
    Replies: 7
    Last Post: 18th March 2010, 07:21
  5. Replies: 5
    Last Post: 19th April 2009, 13:24

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.