How to find a binding loop?

  • 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?

  • 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.

  • Lifetime Qt Champion


    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.

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

  • @NotJo4Ever it does not change anything

  • where exactly are you calling setCurrentIndex?

  • @NotJo4Ever

    onClicked: {
                            selectionModel.setCurrentIndex(styleData.index, ItemSelectionModel.SelectCurrent)////tv1.selection.setCurrentIndex(styleData.index, ItemSelectionModel.SelectCurrent)//
                            //, 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

  • Solved. Problem was in case of using styleData.selected

  • So I was right from our chat?! Score!

Log in to reply