Qt QML TableView:检测到属性“的绑定循环”__scrollBarTopMargin";

Qt QML TableView:检测到属性“的绑定循环”__scrollBarTopMargin";,qt,qml,Qt,Qml,我只是想在QML文件中创建一个TableView,如下所示- TableView { id: resultListTableView anchors.fill: parent rowDelegate: Rectangle { color: "#D3D3D3" height: 30 } itemDelegate: Rectangle { widt

我只是想在QML文件中创建一个TableView,如下所示-

TableView {
        id: resultListTableView
        anchors.fill: parent
        rowDelegate: Rectangle {
            color: "#D3D3D3"
            height: 30
        }

        itemDelegate: Rectangle {
            width: 100
            height: 50
            border.color: "#000000"
            border.width: 1
            Text {
                id: textItem
                text: styleData.value
                anchors.fill: parent
                verticalAlignment: Text.AlignVCenter
                horizontalAlignment: Text.AlignHCenter
                elide: Text.ElideRight
            }
        }

        headerDelegate: Rectangle {
            height: textItem.implicitHeight * 1.2
            width: textItem.implicitWidth
            color: "lightsteelblue"
            Text {
                id: textItem
                anchors.centerIn: parent
                text: styleData.value
                elide: Text.ElideRight
            }
        }

        TableViewColumn {
            role: "file"
            title: "File"
            width: resultListTableView.viewport.width * 0.3
            movable: false
            resizable: false
        }
        TableViewColumn {
            role: "type"
            title: "Type"
            width: resultListTableView.viewport.width * 0.2
            movable: false
            resizable: false
        }
        TableViewColumn {
            role: "size"
            title: "Size"
            width: resultListTableView.viewport.width * 0.2
            movable: false
            resizable: false
        }
        TableViewColumn {
            role: "path"
            title: "Path"
            width: resultListTableView.viewport.width * 0.3
            movable: false
            resizable: false
        }

        model: ResultListDataModel {}
        onDoubleClicked: {
            const element = model.get(row)
            console.log("Downloading file ", element.file, "of size", element.size)
        }
    }
此组件是选项卡视图的一部分,在单击相应选项卡时显示。但当单击选项卡时,我会随机得到一个绑定循环警告:

QML TableView:检测到属性“\uu scrollBarTopMargin”的绑定循环


我没有做任何可能导致这个绑定循环的事情,所以我想知道问题在哪里。有人知道这里发生了什么吗?

没有Qt-dev环境的纯推测,但我猜视口取决于列的宽度,而列的宽度现在取决于视口

划出四行来设置列的宽度将很快证明或反驳这一点

如果这种猜测不起作用,从这里的源代码中,我看到了
\uuuuu scrollBarTopMargin:(\uuu-style&&&uu-style.transientScrollBars | | Qt.platform.os==“osx”)?头部高度:0

您可以考虑对头委托进行黑客攻击,看看它是否删除了警告。


哦,哇,那个身份复制很微妙。正如你自己所说的,复制ID似乎会影响你的尺寸。但愿那是你得到的第一个警告,而不是你真正得到的疯狂的警告

看来你是对的。我会再测试一下,确认一下,然后接受你的答案。谢谢问题似乎是headerDelegate的高度和宽度属性,尽管我不太明白为什么。如果我删除height和width属性,它确实可以工作,但是标题的外观会完全混乱。如您所见,我对QML没有太多经验。有什么想法吗?又一次在黑暗中拍摄,但我想知道是否是显式设置高度和宽度而不是设置代理的隐含高度和宽度导致了这种情况。如果将这些行切换为设置隐含高度和宽度,是否在没有警告的情况下获得所需的行为?您是指隐式高度和隐式宽度吗?如果是,那也不行。我是指隐式宽度和隐式宽度。伙计,关于页眉代表的例子很少。我想知道从代理内部设置矩形的高度是否是正确的方法,但我无法指出示例或反例。我在QtQuick也有一年半的时间了。如果你只是不设置这些属性,我假设视觉上出现了问题?