作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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/
我有这段 QML 代码: Column { spacing: units.gu(2) anchors { fill: parent cente
file:///home/biergaizi/WeCase.commit/src//ui/SmileyDelegate.qml:6:5: QML Column: Cannot specify top,
我是一名优秀的程序员,十分优秀!