0
MouseArea 요소가 포함 된 QT QML에 Item을 만들었습니다. 여기 MouseArea의 그리드 Qt QML
는import QtQuick 1.0
Rectangle {
id: base
width: 240
height: 320
x:0; y:0
color: "#323138"
/////////////////////// MAIN FOCUSSCOPE //////////////////////
FocusScope {
id: mainfocus
height: base.height; width: base.width
focus: true
/////////////////////// MAIN GRID ///////////////////////////
GridView {
id: maingrid
width: base.width-10; height: base.height-titlebar.height-10
x: 5; y: titlebar.height+5;
cellHeight: maingrid.height/3; cellWidth: maingrid.width/3-1
Component {
id: myicon
Rectangle {
id: wrapper
height: maingrid.cellHeight-10; width: maingrid.cellWidth-10
radius: 8; smooth: true
color: GridView.isCurrentItem ? "#c0d0c0" : "transparent"
focus: true
MouseArea {
id: clickable
anchors.fill: wrapper
hoverEnabled: true
//onClicked: func()
}
Image {
id: iconpic
source: "./ui6.svg"
anchors.centerIn: wrapper
}
Text {
id: iconname
color: wrapper.GridView.isCurrentItem ? "black" : "#c8dbc8"
anchors.top: iconpic.bottom; anchors.horizontalCenter: iconpic.horizontalCenter
text: name
}
}
}
model: 4
delegate: myicon
focus: true
}
}
//////////////////////// TITLEBAR ///////////////////////
Rectangle {
id: titlebar
x:base.x
y:base.y
height: 25; width: base.width
color : "#356f47"
Text {
color: "#fdfdfd"
anchors.centerIn: titlebar
text: "title"
}
}
}
내가 그것을 나에게 내가 다른 기능에 사용할 수있는 만든 맞춤 제작 한 클릭 수 항목의 그리드를 제공하도록 이러한 항목의 격자를 만들고 싶어, 코드입니다.
GridView 요소를 사용하여 만든 사용자 정의 항목의 번호를 템플릿으로 사용하는 격자를 만들 수있었습니다.
문제는이 항목 중 하나를 클릭하면 내 항목에 하나의 MouseArea 요소가 있기 때문에 단일 기능을 실행한다는 것입니다. 항목에 대한 클릭을 감지 할 수는 있지만 클릭 한 항목을 고유하게 결정할 수는 없습니다. 이것을 어떻게 성취합니까?
물론 잘못된 것일 수 있으므로 다른 제안도 환영합니다. 감사합니다