Results 1 to 3 of 3

Thread: Model Drag'n'Drop - Default Move

  1. #1
    Join Date
    Apr 2006
    Location
    Minsk, Belarus
    Posts
    23
    Thanks
    3
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Model Drag'n'Drop - Default Move

    The QT reference article on models subclassing says that

    However, it is also possible to customize the way items are encoded during drag and drop operations, whether they are copied or moved by default, and how they are inserted into existing models.
    but I cannot find any evident way of setting the default drag/drop action to move and disabling the copy operation at all since there's no "copy" in my app.

    Can someone give me a hint?

    Thanks!

  2. #2
    Join Date
    Dec 2006
    Posts
    9
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Model Drag'n'Drop - Default Move

    Hello Lemming,

    I was facing the same problem a few days ago and to be short I don't find a way to solve this on the model side.

    The model provides a method to tell which drop actions are supported:
    Qt Code:
    1. Qt::DropActions QAbstractItemModel::supportedDropActions () const
    To copy to clipboard, switch view to plain text mode 
    This method must be overwritten and return Qt::MoveAction, so the model won't accept any "CopyDrops".

    On the drag-site there is the method
    Qt Code:
    1. void QAbstractItemModel::setSupportedDragActions ( Qt::DropActions actions )
    To copy to clipboard, switch view to plain text mode 
    which can be used to set the supported actions. These actions are queried by the view when a drop is started using QAbstractItemModel::supportedDragActions(), but somehow this doesn't work as expected, the standard list or tree view always creates a "CopyDrop", and I didn't find a way to prevent this.

    The only thing you can do is to subclass the view you are using and overwrite the startDrag method, and force it to make a Qt::MoveAction when the drag event starts.

    The above mentioned methods were introduced in qt-4.2 and I was trying with 4.2.1.

    Hope it helps.

  3. #3
    Join Date
    Apr 2006
    Location
    Minsk, Belarus
    Posts
    23
    Thanks
    3
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Model Drag'n'Drop - Default Move

    Quote Originally Posted by ggrinder View Post
    The only thing you can do is to subclass the view you are using and overwrite the startDrag method, and force it to make a Qt::MoveAction when the drag event starts.Hope it helps.
    That's exactly what I was thinking about but decided to leave for "Plan B".

    Looks like I'll have to ask the Trolltech support...

Similar Threads

  1. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 21:17

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.