import QtQuick import QtQuick.Controls 2.5 import QtQuick.Layouts 1.3 Rectangle { id: schedulList width: parent.width height: parent.height color: 'transparent' property StackView stack: null Component.onCompleted: { } function stateText(value) { if(value==0) return '(离线)'; else if(value==1) return '(等待)'; else return '(使用中)'; } Rectangle { width: parent.width height: parent.height anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter color: 'transparent' border.width:1 border.color:"red" GridView { id: carGrid anchors.fill: parent cellWidth: 300 cellHeight: 300 focus: true anchors.leftMargin: 160 anchors.rightMargin: 160 anchors.topMargin: 160 anchors.bottomMargin: 160 x:100 model: appModel.car /* Rectangle { width: 350 height: 350 radius: 5 // border.color: mainAppColor color: 'transparent' } */ delegate: Item { required property string name required property int uid required property string state width: 300 height: 300 Image { id: myIcon width: 200 height: 200 anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter fillMode: Image.PreserveAspectFit source: 'qrc:/images/car1.png' } Text { anchors { top: myIcon.bottom topMargin: 10 horizontalCenter: parent.horizontalCenter } text: parent.name + stateText(parent.state) color: '#eaf4fc' font.family: alibaba.name font.pointSize: 20 Timer{ id: timerRefresh interval:1000 onTriggered: { stateText(parent.state) } } } MouseArea { anchors.fill: parent onClicked: { if(appModel.idle(parent.uid)) { parent.GridView.view.currentIndex = parent.uid console.log(parent.GridView.view.currentIndex) //carSelect(parent.GridView.view.currentIndex) page_detail.visible = true page_detail.stack = stack page_detail.refresh() stack.push(page_detail, { "name": parent.name, "uid": parent.uid }) } } } } } } }