【发布时间】:2017-12-08 01:49:06
【问题描述】:
我在 Flickable 中有一个 backGroundList 和顶部 gridview。
我想处理来自父 Flickable 的 gridview contentY 和 Y 位置,当我将 gridview 高度指定为内容高度时它正在工作,但由于内存问题我不想之前创建项目。
代码:
Flickable {
id: mainFlickable
width: 1920
height: 1080
contentHeight: gridView.contentHeight + 660 + 140 // topmargin + bottom margin
ListView {
id:backGroundList
width: 1920
height: 1080
y: mainFlickable.contentY
orientation: ListView.Horizontal
MouseArea {
id: myMA12
anchors.fill: parent
hoverEnabled: true
}
}
GridView {
id: gridView
objectName: "gridView"
width: 1920
height: 1080
cellWidth: 372
cellHeight: 290
interactive: false
y: {
if (mainFlickable.contentY > 660)
return 660 + (mainFlickable.contentY - 660)
else
return 660
}
contentY: {
if (mainFlickable.contentY > 660){
return (mainFlickable.contentY - 660)
}
else {
return 0
}
}
delegate: Rectangle {
width: 352
height: 270
color: "blue"
opacity: 0.5
Text {
text: index
anchors.centerIn: parent
}
}
model:100
anchors {
left: parent.left
leftMargin: 30
right: parent.right
rightMargin: 30
}
}
}
它没有按预期工作。 当我更新 Y 值时,ContentY 会自动更新为零
约束:Qt5.9.0
有人可以帮我解决这个问题吗?
【问题讨论】:
-
您能否提供一个快速的线框图,说明您希望您的 UI 是什么样子?让我们更深入地了解您的需求。我觉得您在将 2
Flickables嵌套到 1 时走错了路(ListView和GridView都继承自Flickable)