Qt GridView:leftMargin和rightMargin属性不起作用
对于Qt GridView:leftMargin和rightMargin属性不起作用,qt,qml,qtquick2,Qt,Qml,Qtquick2,对于Flickable(即Flickable具有Grid和相同的矩形(见下面的代码)的Flickable),它可以工作 以下是GridView的一个示例: import QtQuick 2.7 import QtQuick.Controls 1.4 ApplicationWindow { id: rootWindow visible: true width: 300 height: 300 Rectangle { anchors.fi
Flickable
(即Flickable
具有Grid
和相同的矩形(见下面的代码)的Flickable
),它可以工作
以下是GridView的一个示例:
import QtQuick 2.7
import QtQuick.Controls 1.4
ApplicationWindow {
id: rootWindow
visible: true
width: 300
height: 300
Rectangle {
anchors.fill: parent
color: "yellow"
GridView {
id: gridView
anchors.fill: parent
cellWidth: 50
cellHeight: 50
model: 54
bottomMargin: 10
topMargin: 10
leftMargin: 10 // this doesn't work
rightMargin: 10 // this doesn't work
delegate: Rectangle {
width: gridView.cellWidth - 1
height: gridView.cellHeight - 1
color: "green"
}
}
}
}
也许这就是你想要的:
...
GridView {
id: gridView
anchors {
fill: parent
margins: 10
}
clip: true
cellWidth: 50
cellHeight: 50
model: 54
delegate: Rectangle {
width: gridView.cellWidth - 1
height: gridView.cellHeight - 1
color: "green"
}
}
...
看起来smth怪异正在发生,真的-我会把这个存档,看看他们怎么说。GridXXX的东西有很多问题,我想,所以没有什么好惊讶的。这将修剪GridView的鼠标区域,也就是说,当鼠标在边距上时,你将无法滚动。