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 find a binding loop?

How to find a binding loop?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
9 Posts 3 Posters 3.3k 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.
  • K Offline
    K Offline
    Kofr
    wrote on last edited by
    #1

    Hi, I am getting this message from Qt

    file:///D:/dev/tools/Qt/5.7/mingw53_32/qml/QtQuick/Controls/Private/BasicTableView.qml:551:13: QML FocusScope: Binding loop detected for property "itemSelected"
    

    I work on quite complex project and I use

    TableViewColumn {
                        id: column
                        width: tv1.width
     }
    

    with TreeView
    The error comes up when I use SelecionModel

    selectionModel.setCurrentIndex(styleData.index, ItemSelectionModel.SelectCurrent)
    
    ...
    selection: ItemSelectionModel  {
                        id: selectionModel
                        model: tv1.model
                    }
    

    How to find source of such error?
    How to debug so I can find the origin?

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NotJo4Ever
      wrote on last edited by
      #2

      Try referencing the selection model by retrieving it from the TreeView instead of by id... And try giving the SelectionFlag as an int. See if either of those suggestions work. I have code that does something almost identical to what you are doing and am not receiving a binding loop.

      TreeView {
      id: tree
      ...
      selection: ItemSelectionModel {
              model: tv1.model
          }
      ...
      }
      
      //Somewhere else I call the following.
      tree.selection.setCurrentIndex( styleData.index, 3 );
      

      Where 3 is Equivalent to QItemSelectionModel::ClearAndSelect

      Works fine for me. More detail may be necessary as it is very possible that you are calling "setCurrentIndex" in the wrong place.

      K 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        I've seen recently that there's a small tool to help finding these loops that might be of interest.

        See here

        Hope it helps.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        K 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          I've seen recently that there's a small tool to help finding these loops that might be of interest.

          See here

          Hope it helps.

          K Offline
          K Offline
          Kofr
          wrote on last edited by
          #4

          @SGaist this tool does not work. Have you tried?
          I think the problem is in BasicTableView as I could not find loop manually yet.

          1 Reply Last reply
          0
          • N NotJo4Ever

            Try referencing the selection model by retrieving it from the TreeView instead of by id... And try giving the SelectionFlag as an int. See if either of those suggestions work. I have code that does something almost identical to what you are doing and am not receiving a binding loop.

            TreeView {
            id: tree
            ...
            selection: ItemSelectionModel {
                    model: tv1.model
                }
            ...
            }
            
            //Somewhere else I call the following.
            tree.selection.setCurrentIndex( styleData.index, 3 );
            

            Where 3 is Equivalent to QItemSelectionModel::ClearAndSelect

            Works fine for me. More detail may be necessary as it is very possible that you are calling "setCurrentIndex" in the wrong place.

            K Offline
            K Offline
            Kofr
            wrote on last edited by
            #5

            @NotJo4Ever it does not change anything

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NotJo4Ever
              wrote on last edited by
              #6

              where exactly are you calling setCurrentIndex?

              K 1 Reply Last reply
              0
              • N NotJo4Ever

                where exactly are you calling setCurrentIndex?

                K Offline
                K Offline
                Kofr
                wrote on last edited by
                #7

                @NotJo4Ever

                onClicked: {
                                        selectionModel.setCurrentIndex(styleData.index, ItemSelectionModel.SelectCurrent)////tv1.selection.setCurrentIndex(styleData.index, ItemSelectionModel.SelectCurrent)//
                                        //selectionModel.select(styleData.index, ItemSelectionModel.SelectCurrent)
                                        mainW.contentX = tv1.itemIndention * (styleData.depth + 0.9) //0.9 is alignment coefficient
                                    }
                

                handler of delegate's signal clicked(var mouse) which is generated on click over current delegate

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  Kofr
                  wrote on last edited by
                  #8

                  Solved. Problem was in case of using styleData.selected

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    NotJo4Ever
                    wrote on last edited by
                    #9

                    So I was right from our chat?! Score!

                    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