还是 QML GridView 翻页问题 (vegata来指导下)
vegata 我按照你给的方法,可以实现左右分页,但我想改成上下翻页的时候,GridView就不跟着动了。我错在那边了?
会的大神也指导下吧
import QtQuick 1.0
Item {
width: 319
height: 150
Image {
id: image1
anchors.fill: parent
Item {
id: item1
anchors.rightMargin: 4
anchors.leftMargin: 3
anchors.bottomMargin: 4
anchors.topMargin: 27
anchors.fill: parent
ListView {
id:listView
anchors.fill: parent
model: listModel
delegate: listDel
// orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
}
GridView {
id:gridView
anchors.fill: parent
model:gridModel
delegate: gridDel
cellHeight : height/5-1
cellWidth : width
//flow:Grid.TopToBottom
interactive: false
contentX: listView.contentX
}
}
}
Component
{
id:gridDel
Item
{
width: gridView.width
height: gridView.height/5-1
Item
{
anchors.centerIn: parent
width: gridView.width
height: gridView.height/5-1
Text
{
id: text2
anchors.centerIn: parent
font.pixelSize:20
text:id;
MouseArea {
id: mouse_area4
anchors.fill: parent
onClicked: {
text2.color = "#ffffff"
}
}
}
}
}
}
ListModel
{
id:gridModel
}
Component
{
id:listDel
Rectangle
{
width: listView.width
height: listView.height
color:"transparent"
border.width:3
border.color: "black"
}
}
ListModel
{
id:listModel
}
Component.onCompleted:
{
for(var i = 0;i<100;++i)
{
gridModel.append({"id":i});
}
for(var j = 0;j<50;++j)
{
listModel.append({});
}
}
}