我正在使用网格视图,它可以从左向右滚动。单击网格视图中的每个项目时,将启动新屏幕,其中包含从当前网格项位置到屏幕宽度和屏幕高度的动画。在网格视图向右滚动后单击第二列元素时,网格项位置出错。有没有什么办法解决这一问题 ?或者有没有方法来检查网格视图是否滚动到最右边?
我的代码如下:
[HttpPost]
public ReturnResponse UpdateEmployeeApprovalStatus(object employeeInfo)
{
Employee emp= JsonConvert.DeserializeObject<Employee>(employeeInfo.ToString());
}
答案 0 :(得分:0)
您要找的是mapFromItem
和mapToItem
功能:
http://doc.qt.io/qt-5/qml-qtquick-item.html#mapFromItem-method-1
Item {
id: rootItem
anchors.fill: parent
Rectangle {
id: myRect
color: 'red'
width: 50
height: 50
// the + 0 * featuresGrid.contentX will force the binding to reevaluate when draged. Maybe you don't want that. Comment it out and try
x: featuresGrid.currentItem.mapToItem(rootItem, 0, 0).x + 0 * featuresGrid.contentX
y: featuresGrid.currentItem.mapToItem(rootItem, 0, 0).y + 0 * featuresGrid.contentY
z: 1
}
GridView {
id: featuresGrid
snapMode: ListView.SnapToItem
clip:true
x: 135
y: 122
width:1650
height:485
cellWidth: 825
cellHeight: 160
flow: GridView.FlowTopToBottom
model:favouriteapp
delegate:featureGridTile
focus: false
}
ListModel {
id:favouriteapp
ListElement {
featureName: "media & radio"
soureIcon:"file:graphics/Icons/MediaIcon.png"
feature:"Media"
}
ListElement {
featureName: "phone"
soureIcon:"file:graphics/Icons/Phoneicon.png"
feature:"Phone"
}
ListElement {
featureName: "climate"
soureIcon:"file:graphics/Icons/ClimateIcon.png"
feature:"Climate"
}
ListElement {
featureName: "navigation"
soureIcon:"file:graphics/Icons/NavIcon.png"
feature:"Navigation"
}
ListElement {
featureName: "ambient lighting"
soureIcon:"file:graphics/Icons/ALIcon.png"
feature:"AL"
}
ListElement {
featureName: "settings"
soureIcon:"file:graphics/Icons/SettingsIcon.png"
feature:"Settings"
}
ListElement {
featureName: "camera"
soureIcon:"file:graphics/Icons/CamIcon.png"
feature:"Camera"
}
ListElement {
featureName: "dynamic-i"
soureIcon:"file:graphics/Icons/dynamicIcon.png"
feature:"Dynamic_I"
}
ListElement {
featureName: "bluetooth"
soureIcon:"file:graphics/Icons/Icon Bluetooth.png"
feature:"Bluetooth"
}
}
}
Component {
id: featureGridTile
Item {
id:grid_view_rect
width:featuresGrid.cellWidth
height:featuresGrid.cellHeight
Rectangle{
anchors.fill: parent
color: "white"
opacity: 1
border.color: 'black'
}
Text{
anchors.fill: parent
text : featureName
opacity: 1
}
MouseArea{
anchors.fill: parent
onClicked: {
featuresGrid.currentIndex = index
//Goes to the next screen with the current clicked grid item X and Y position
}
}
}
}