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
Forum Updated to NodeBB v4.3 + New Features

qml drag and drop with separate windows

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 186 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 3 May 2023, 13:58 last edited by Mihaill 5 Mar 2023, 14:58
    #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 3 May 2023, 15:51
    0
    • M Mihaill
      3 May 2023, 13:58

      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 3 May 2023, 15:51 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 3 May 2023, 15:51

      1/2

      3 May 2023, 13:58

      • Login

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