Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to do DnD with Qt5.1.0 QML TableView?
Forum Updated to NodeBB v4.3 + New Features

How to do DnD with Qt5.1.0 QML TableView?

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 896 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    allopen
    wrote on last edited by
    #1

    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.0

    ApplicationWindow {
    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 / 2

                text: 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"
            }
        }
    }
    

    }
    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved