Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Moving a widget in Drag&Drop

Moving a widget in Drag&Drop

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 996 Views 3 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.
  • S Offline
    S Offline
    ShinSat
    wrote on last edited by
    #1

    Hello Gurus,

    I'm trying but no luck so far. It would be great if anyone could direct me to a right way. :)

    Now I'm trying drag&drop capability between multiple QMainWindows.
    I want to drag a widget on a QMainwindow to another widget on another QMainwindow by visually moving the dragged widget, that is, drag&drop.

    Just to move widget, I reimplemented mouseMoveEvent/mousePressEvent/mouseReleasedEvent and it worked, but if I included the creation of Qdrag object in the mousePressEvent, I noticed I couldn't receive mouseReleasedEvent. I guess it's because dropEvent overwrites it... :<

    Is there a way to coexist drag&drop and move functionalities?

    Many thanks in advance for your help.
    Sat

    S 1 Reply Last reply
    0
    • S ShinSat

      Hello Gurus,

      I'm trying but no luck so far. It would be great if anyone could direct me to a right way. :)

      Now I'm trying drag&drop capability between multiple QMainWindows.
      I want to drag a widget on a QMainwindow to another widget on another QMainwindow by visually moving the dragged widget, that is, drag&drop.

      Just to move widget, I reimplemented mouseMoveEvent/mousePressEvent/mouseReleasedEvent and it worked, but if I included the creation of Qdrag object in the mousePressEvent, I noticed I couldn't receive mouseReleasedEvent. I guess it's because dropEvent overwrites it... :<

      Is there a way to coexist drag&drop and move functionalities?

      Many thanks in advance for your help.
      Sat

      S Offline
      S Offline
      ShinSat
      wrote on last edited by
      #2

      @ShinSat Looks like mouseMoveEvent is not available during Qdrag.MoveAction... :<

      Sat

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Can you show a minimal compilable example that shows what you are trying to do ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          Can you show a minimal compilable example that shows what you are trying to do ?

          S Offline
          S Offline
          ShinSat
          wrote on last edited by
          #4

          @SGaist My scenario is some thing like that a widget moves in mouseMoveEvent and QDrag object is created in mousePressEvent.

          def mousePressEvent(self):
              ...
              ...
              mime = QMimeData()
              mime.setData( ... )
              ...
             qdrag = QDrag()
             ....
             qdrag.exec(Qt.MoveAction)
             ...
          
          def mouseMoveEvent(self, event):
              # calculate the position moving to
             self.mvoe(x, y)
          

          The problem is mouseMoveEvent is not ivoked during Qt.MoveAction.
          How can I deal with that?

          Sat

          S 1 Reply Last reply
          0
          • S ShinSat

            @SGaist My scenario is some thing like that a widget moves in mouseMoveEvent and QDrag object is created in mousePressEvent.

            def mousePressEvent(self):
                ...
                ...
                mime = QMimeData()
                mime.setData( ... )
                ...
               qdrag = QDrag()
               ....
               qdrag.exec(Qt.MoveAction)
               ...
            
            def mouseMoveEvent(self, event):
                # calculate the position moving to
               self.mvoe(x, y)
            

            The problem is mouseMoveEvent is not ivoked during Qt.MoveAction.
            How can I deal with that?

            Sat

            S Offline
            S Offline
            ShinSat
            wrote on last edited by ShinSat
            #5

            @ShinSat Update:
            Now I'm changing my approach and testing it.
            Actually, I isolated drag&drop and moving the widget. In other words, without dropEvent, the destination widget accepts the mouseReleaseEvent when it's under the cursor. The source widget drops into the destination. The advantage of this approach doesn't require QDrag object.

            Sat

            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