Results 1 to 3 of 3

Thread: Drag&Drop - Pointer into QMimeData?

  1. #1
    Join Date
    Oct 2009
    Posts
    3
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Wink Drag&Drop - Pointer into QMimeData?

    Hi,
    I'm new to Qt - it's really cute, but I don't fully understand how drag/drop is really working. I've done some tutorials already, but neither they nor google could answer my question.
    I have a two QTreeWidgets with custom Items; and I want Qt to do the following:
    If the user drags an Item from Widget A to Widget B, it gets "linked" to it:
    I create a new special Item in B, and want to have a "pointer" property that points to the original item in A.
    QMimeData can only handle Text, URLs etc, but no pointers.
    How do I do that? Do I have to subclass QMimeData just for doing that?

    Can I somehow "link" an Item from QTreeWidget A to QTreeWidget B without copying it? (I think not)

    How do I properly conversion between a pointer and the ByteArray QMimeData wants?

  2. #2
    Join Date
    Nov 2008
    Location
    Częstochowa/Poland
    Posts
    50
    Thanks
    2
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drag&Drop - Pointer into QMimeData?

    Have a look at Q_DECLARE_METATYPE ( Type ) and QVariant
    Me, Grimlock, not "nice dino". ME BASH BRAINS!

  3. #3
    Join Date
    Oct 2009
    Posts
    3
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drag&Drop - Pointer into QMimeData?

    yes, I stumbled upon thosw two as well.
    I couldn't believe that I have to subclass so many classes just to provide drag&drop.

    I got it working by just subclassing QMimeData and implementing another member variable with that pointer, was the easiest way - drag&drop works now as expected.

    In meantime I will change the TreeWidget to a TreeView and create a proper Model underneath all of it - this seems to help me. But I thought I could get around that ;-)

    in some things Qt is little straightforward. You have to define so many things yourself.
    I was used to Delphi/Pascal, things are MUCH easier there.
    But yes, in the end in Qt the approach is cleaner - IF you manage it...
    thanky anyway,
    Christian

Similar Threads

  1. Dragging a pointer
    By Cruz in forum Qt Programming
    Replies: 4
    Last Post: 10th July 2009, 04:51
  2. pointer in a class
    By mickey in forum General Programming
    Replies: 23
    Last Post: 26th May 2008, 16:52
  3. Is there a known problem with QMimeData on Mac OS X?
    By Wurgl in forum Qt Programming
    Replies: 8
    Last Post: 27th February 2008, 23:21
  4. cursor pixmap during drag&drop
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 16:55
  5. Passing a pointer in Signal/Slot Connection
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 6th November 2007, 20:04

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.