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. qml drag and drop with separate windows

qml drag and drop with separate windows

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 246 Views
  • 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.
  • M Offline
    M Offline
    Mihaill
    wrote on last edited by Mihaill
    #1

    Hi.
    I have 2 windows in my app.
    When I use drag and drop in one window - all work fine.
    But I can't get drop signal in second windows. And mouse icon showing drap only in one window.

            Tree {
            
                        id: tree
            
                        filterClassType: [ EnumsLibrary.objectTypes.TDevice, EnumsLibrary.objectTypes.TModule, EnumsLibrary.objectTypes.TSensor ]
            
                        headerVisible: false
            
                        autoExpand: false
            
            
            
                        itemDelegate: Item {
            
                            id: objectTree
            
            
            
                            Text {
            
                                id: objectTreeName
            
                                property var params: styleData.value
            
                                property string type: "tree"
            
                                anchors.verticalCenter: parent.verticalCenter
            
                                anchors.left: parent.left
            
                                color: "black"
            
                                elide: styleData.elideMode
            
                                text: styleData.value['Name'] !== undefined ? styleData.value['Name'] : "ИМЯ НЕ УСТАНОВЛЕНО"
            
            
            
            //                    Drag.keys: [ "any" ]
            
                                Drag.active: mouseAreaTree.drag.active
            
                                Drag.hotSpot.x: 1
            
                                Drag.hotSpot.y: 10
            
            //                    Drag.mimeData: params
            
                                Drag.mimeData: {"text/plain": "Copied text"}
            
                                Drag.onActiveChanged: {
            
                                    console.log("444444444444444444444444444444444444", Drag.active)
            
                                    if (Drag.active) {
            
            //                            Drag.imageSource = "qrc:/assets/add_window.svg"
            
                                    }
            
                                }
            
                            }
            
            
            
            //                states: State {
            
            //                    when: mouseAreaTree.drag.active
            
            //                    ParentChange { target: objectTreeName; parent: root }
            
            //                    AnchorChanges { target: objectTreeName; anchors.verticalCenter: undefined; anchors.left: undefined }
            
            //                }
            
            
            
                            MouseArea {
            
                                id: mouseAreaTree
            
                                anchors.fill: parent
            
                                drag.target: objectTreeName
            
            
            
                                onReleased: {
            
                                    objectTreeName.Drag.drop()
            
                                    objectTreeName.parent = objectTreeName.Drag.target !== null ? objectTreeName.Drag.target : objectTree
            
                                }
            
            
            
                                onDoubleClicked: {
            
                                    dataModel.dispatcher.switchToTabObjects()
            
                                    /// TODO при открытии объекта, слева в сайдбаре этот элемент также должен быть выделен
            
                                    /// (как будто по нему кликнули)
            
                                    objectsController.objectClicked( styleData.value['Uuid_'] )
            
                                }
            
                            }
            
                        }
            
                    }
    M 1 Reply Last reply
    0
    • M Mihaill

      Hi.
      I have 2 windows in my app.
      When I use drag and drop in one window - all work fine.
      But I can't get drop signal in second windows. And mouse icon showing drap only in one window.

              Tree {
              
                          id: tree
              
                          filterClassType: [ EnumsLibrary.objectTypes.TDevice, EnumsLibrary.objectTypes.TModule, EnumsLibrary.objectTypes.TSensor ]
              
                          headerVisible: false
              
                          autoExpand: false
              
              
              
                          itemDelegate: Item {
              
                              id: objectTree
              
              
              
                              Text {
              
                                  id: objectTreeName
              
                                  property var params: styleData.value
              
                                  property string type: "tree"
              
                                  anchors.verticalCenter: parent.verticalCenter
              
                                  anchors.left: parent.left
              
                                  color: "black"
              
                                  elide: styleData.elideMode
              
                                  text: styleData.value['Name'] !== undefined ? styleData.value['Name'] : "ИМЯ НЕ УСТАНОВЛЕНО"
              
              
              
              //                    Drag.keys: [ "any" ]
              
                                  Drag.active: mouseAreaTree.drag.active
              
                                  Drag.hotSpot.x: 1
              
                                  Drag.hotSpot.y: 10
              
              //                    Drag.mimeData: params
              
                                  Drag.mimeData: {"text/plain": "Copied text"}
              
                                  Drag.onActiveChanged: {
              
                                      console.log("444444444444444444444444444444444444", Drag.active)
              
                                      if (Drag.active) {
              
              //                            Drag.imageSource = "qrc:/assets/add_window.svg"
              
                                      }
              
                                  }
              
                              }
              
              
              
              //                states: State {
              
              //                    when: mouseAreaTree.drag.active
              
              //                    ParentChange { target: objectTreeName; parent: root }
              
              //                    AnchorChanges { target: objectTreeName; anchors.verticalCenter: undefined; anchors.left: undefined }
              
              //                }
              
              
              
                              MouseArea {
              
                                  id: mouseAreaTree
              
                                  anchors.fill: parent
              
                                  drag.target: objectTreeName
              
              
              
                                  onReleased: {
              
                                      objectTreeName.Drag.drop()
              
                                      objectTreeName.parent = objectTreeName.Drag.target !== null ? objectTreeName.Drag.target : objectTree
              
                                  }
              
              
              
                                  onDoubleClicked: {
              
                                      dataModel.dispatcher.switchToTabObjects()
              
                                      /// TODO при открытии объекта, слева в сайдбаре этот элемент также должен быть выделен
              
                                      /// (как будто по нему кликнули)
              
                                      objectsController.objectClicked( styleData.value['Uuid_'] )
              
                                  }
              
                              }
              
                          }
              
                      }
      M Offline
      M Offline
      Mihaill
      wrote on last edited by
      #2

      @Mihaill need using

                          Item {
                                          id: draggable
                                          anchors.fill: parent
                          Drag.dragType: Drag.Automatic
      //                    Drag.keys: [ "any" ]
                          Drag.active: mouseAreaTree.drag.active
                          Drag.hotSpot.x: 1
                          Drag.hotSpot.y: 10
                          Drag.mimeData: params
      //                    Drag.mimeData: {"text/plain": "Copied text"}
                          Drag.onActiveChanged: {
                              console.log("444444444444444444444444444444444444", Drag.active)
                              if (Drag.active) {
      //                            Drag.imageSource = "qrc:/assets/add_window.svg"
                              } else {
                                  Drag.drop()
                              }
                          }
                          }
      
      1 Reply Last reply
      0
      • M Mihaill has marked this topic as solved on

      • Login

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