gpt4 book ai didi

qt - 列内项目的错误 : QML Column: Cannot specify top, 底部、verticalCenter、fill 或 centerIn anchor

转载 作者:行者123 更新时间:2023-12-02 00:51:46 25 4
gpt4 key购买 nike

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 + ']')
}
}
}
}

最佳答案

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

如果您将 MouseArea 从 Column 移出并移至 SmileyDelegate 的基本 Item 中,您可能会发现它按照您的预期工作。

关于qt - 列内项目的错误 : QML Column: Cannot specify top, 底部、verticalCenter、fill 或 centerIn anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15871583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com