{"id":1142,"date":"2022-08-30T15:13:05","date_gmt":"2022-08-30T15:13:05","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/how-to-make-tableview-items-draggable-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:13:05","modified_gmt":"2022-08-30T15:13:05","slug":"how-to-make-tableview-items-draggable-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-to-make-tableview-items-draggable-collection-of-common-programming-errors\/","title":{"rendered":"How to make TableView Items draggable-Collection of common programming errors"},"content":{"rendered":"<p>I\u2019ve a TableView and have implemented my own item delegate for it. I want to be able to drag it out and place it somewhere else. How do I do it<\/p>\n<pre><code>itemDelegate: Text {\n    id: objMainText\n    anchors.horizontalCenter: parent.horizontalCenter\n\n    elide: styleData.elideMode\n    color: \"yellow\"\n\n    text: styleData.value.get(0).content \/\/assume this is correct\n\n    MouseArea {\n        id: objDragArea\n\n        anchors.fill: parent\n        drag.target: objDragableText\n        drag.axis: Drag.XAndYAxis\n\n        hoverEnabled: true\n\n        onEntered: {\n            console.log(\"Hover Captured\")          \/\/This gets printed\n        }\n\n        onClicked: {\n            console.log(\"Detected\")                     \/\/This NEVER gets printed\n        }\n\n        Text {\n            id: objDragableText\n            anchors.verticalCenter: parent.verticalCenter\n            anchors.horizontalCenter: parent.horizontalCenter\n            Drag.active: objDragArea.drag.active\n            opacity: Drag.active \/ 2\n\n            text: objMainText.text\n            color: objMainText.color\n\n            states: State {\n                when: { objDragArea.drag.active }\n                AnchorChanges {\n                    anchors.horizontalCenter: undefined\n                    anchors.verticalCenter: undefined\n                }\n            }\n        }\n    }\n}\n<\/code><\/pre>\n<p>Don\u2019t mind if there are a few brackets less here and there. Those I\u2019m taking care of ofcourse. But why can\u2019t I drag <code>objDragableText<\/code> and how do i do it? Also, <code>onClicked<\/code> is captured as in the comments above but not <code>onPressed<\/code>. How do I also do this?<\/p>\n<p>{Qt 5.1 RC 1 &#8211; Win7 &#8211; MinGw 4.8}<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:32:04. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I\u2019ve a TableView and have implemented my own item delegate for it. I want to be able to drag it out and place it somewhere else. How do I do it itemDelegate: Text { id: objMainText anchors.horizontalCenter: parent.horizontalCenter elide: styleData.elideMode color: &#8220;yellow&#8221; text: styleData.value.get(0).content \/\/assume this is correct MouseArea { id: objDragArea anchors.fill: parent drag.target: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1142","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1142"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1142\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}