我有一个TableView,并为它实现了我自己的项目委托。我希望能够将它拖出来并放在其他地方。我该怎么做
itemDelegate: Text {
id: objMainText
anchors.horizontalCenter: parent.horizontalCenter
elide: styleData.elideMode
color: "yellow"
text: styleData.value.get(0).content //assume this is correct
MouseArea {
id: objDragArea
anchors.fill: parent
drag.target: objDragableText
drag.axis: Drag.XAndYAxis
hoverEnabled: true
onEntered: {
console.log("Hover Captured") //This gets printed
}
onClicked: {
console.log("Detected") //This NEVER gets printed
}
Text {
id: objDragableText
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
Drag.active: objDragArea.drag.active
opacity: Drag.active / 2
text: objMainText.text
color: objMainText.color
states: State {
when: { objDragArea.drag.active }
AnchorChanges {
anchors.horizontalCenter: undefined
anchors.verticalCenter: undefined
}
}
}
}
}
不要介意这里和那里是否有少量括号。那些我正在照顾的人。但为什么我不能拖objDragableText
,我该怎么做?
此外,onClicked
被捕获,如上面的评论中所示,但不是onPressed
。我怎么也这样做?
{Qt 5.1 RC 1 - Win7 - MinGw 4.8}