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. [Solved] Drag&Drop without QDrag
QtWS25 Last Chance

[Solved] Drag&Drop without QDrag

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • T Offline
    T Offline
    thEClaw
    wrote on last edited by
    #1

    I will be trying to replace a drag&drop-enabled widget that was based around QDrag with "something else", since QDrag is limiting me too much. I want to be able to drag around widgets (like QLabels) between different "container" widgets. Even QML might be a possibility, but it would have to be integrated with an existing C++ application.

    Right now I am trying to make out problems and come up with a nice idea to implement drag&drop into my application - I would be happy about any kind of input/ideas etc. :)

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

      Hi,

      Can you give an example of what a drag and drop operation would perform ?

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

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thEClaw
        wrote on last edited by
        #3

        I am bundling up some data (could be a couple of megabytes) that is encapsulated by a custom QLabel. The mouse-cursor should be sensitive to where the mouse is currently pointing (if it hits a draggable object, it should change shape). I think that part is already done.

        The label should be movable between a number of widgets of equal type (some kind of container). While a label is being dragged on top of a container, the container should change color (or somehow give away that it would accept the drop).

        After the dragging is done, I want to be able to read out which label has been positioned on which container. And I need some methods to automatically move the labels around, too.

        Right now I am wondering if I should make the label a child of whatever container it is currently belonging to or if the frequent changes of parents will cause problems.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          thEClaw
          wrote on last edited by
          #4

          I finished my Drag&Drop-alternative by now. The code is about 33% shorter than the initial QDrag-code I used (I had a QDrag implementation working but felt limited by it) and it is pretty easy to add graphical features now since I am moving around actual widgets - I don't even have to block the eventloop. The only drawback is that I am unable to drag around objects between applications now - not a feature I need, but it would certainly be a lot more difficult (if not impossible) than when using QDrag (which drags around actual data represented by a pixmap, not a QObject like I do now).

          Thread is declared "solved" then.

          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