How to do DnD with Qt5.1.0 QML TableView?
-
I'v read "this post":http://qt-project.org/forums/viewthread/29514/ but I can't get it work! could someone help me?
@import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0
import QtQuick.Controls.Styles 1.0ApplicationWindow {
title: qsTr("Hello World")
width: 640
height: 480
color: "black"menuBar: MenuBar { Menu { title: qsTr("File") MenuItem { text: qsTr("Exit") onTriggered: Qt.quit(); } } } TableView { anchors.fill: parent visible: true TableViewColumn{ role: "code" ; title: "code" ; width: 100 } TableViewColumn{ role: "name" ; title: "name" ; width: 200 } itemDelegate: Text { id: objMainText anchors.horizontalCenter: parent.horizontalCenter text: styleData.value elide: styleData.elideMode MouseArea { id: objDragArea anchors.fill: parent drag.target: objDragableText drag.axis: Drag.XAndYAxis hoverEnabled: true onEntered: { console.log("Hover Captured") //This gets printed } onPressed: { mouse.accepted = false console.log("Detected") //This NEVER gets printed } } Text { id: objDragableText
// anchors.verticalCenter: parent.verticalCenter
// anchors.horizontalCenter: parent.horizontalCenter
Drag.active: objDragArea.drag.active
opacity: 1//Drag.active / 2text: objMainText.text color: "red"//objMainText.color
// states: State {
// when: { objDragArea.drag.active }
// AnchorChanges {
// anchors.horizontalCenter: undefined
// anchors.verticalCenter: undefined
// }
// }
}} model: ListModel { ListElement { name: "abc" code: "30426" } ListElement { name: "def" code: "32235" } ListElement { name: "fgh" code: "32638" } } }
}
@