错误:QML列:无法为列中的项指定顶部、底部、垂直居中、填充或居中锚点。

10
file:///home/biergaizi/WeCase.commit/src//ui/SmileyDelegate.qml:6:5: 
QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn 
anchors for items inside Column

为什么我会得到这个东西?我试图注释每一行代码,但是没有找到答案。我对此毫无头绪。

SmileyView.qml

import QtQuick 1.0

Rectangle {
    width: 300; height: 200


    GridView {
        id: grid
        anchors.fill: parent
        cellWidth: 36; cellHeight: 40

        model: SmileyModel
        delegate: SmileyDelegate {}
        highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
        focus: true
    }
}

SmileyDelegate.qml

import QtQuick 1.0

Item {
    width: grid.cellWidth; height: grid.cellHeight

    Column {
        anchors.fill: parent
        Image { source: path; anchors.horizontalCenter: parent.horizontalCenter }
        Text { text: name; anchors.horizontalCenter: parent.horizontalCenter }

        MouseArea {
            anchors.fill: parent
            onClicked: {
                highlight: color: "lightsteelblue"; radius: 5 
                grid.currentIndex = index 
            }
            onDoubleClicked: {
                parentWindow.returnSmileyName('[' + name + ']')
            }
        }
    }
}
1个回答

6

Column试图将您的MouseArea锚定到Image和Text旁边,但MouseArea指定其锚定填充其父级。这两件事是矛盾的,因此您会收到错误。

如果将MouseArea移出Column并移到SmileyDelegate的基本项中,则可能会按预期工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接