import QtQuick 2.0
Rectangle{
width: 240;
height: 300;
color: "white"
GridView{
anchors.fill: parent
anchors.margins: 20
clip: true // 设置clip属性为true,来激活裁剪功能
model:40
delegate: numberDelegate
cellHeight: 45
cellWidth: 45
header: headerComponent // 页眉
footer: footerComponent // 页脚
}
Component{
id:headerComponent
Rectangle{
width: 40;
height: 20;
color: "yellow"
}
}
Component{
id:footerComponent
Rectangle{
width: 40;
height: 20;
color: "yellow"
}
}
Component{
id:numberDelegate
Rectangle{
width: 40;
height: 40;
color: "lightGreen"
Text {
anchors.centerIn: parent
font.pixelSize: 10
text: index
}
}
}
}