Results 1 to 5 of 5

Thread: Drag and Drop in QT4

  1. #1
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default Drag and Drop in QT4

    I m porting code from QT3 to QT4

    I have a widget with 2 frames, one with some drag-able icons, and another a ListView tree
    In the past(QT3), I can drag the icon to the ListView tree. However after porting to QT4, I can't drag that!(seems the area of the ListView does not allow the icon to drag in)

    Can anyone tell me why and how can I set that back???

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drag and Drop in QT4

    What should the listview do with the icons?

    If you really are using a QListView, you will need a "model" for it. Both the QListView (QAbstractItemView::setDragDropMode()) and the model (QAbstractItemModel::mimeTypes(), QAbstractItemModel::dropMimeData()) need to support DnD.
    For details see: model-view-dnd
    (You are aware the the rought equivalent of a Qt3 "list view" is a QTreeWidget?)

    HTH

  3. #3
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default Re: Drag and Drop in QT4

    Actually I m using the Q3ListView

    What I want to do is just like there is a tree with some nodes(which are some folder) or left side, and there are some icons on the right(IconView items), and can drag the icon to different nodes.

    Actually the code works well in QT3, so I want to know is there anything I need to set in order to let the tree listview accept the icon drag.

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drag and Drop in QT4

    have you set setAcceptDrops(true)?

  5. #5
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default Re: Drag and Drop in QT4

    Yes, I have set that
    I think the problem now is that there's still a "no entry" icon shown when I drag the item to the ListView tree, which means even I have set setAcceptDrop(true), seems it still reject dropping....... >.<

Similar Threads

  1. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 17:56
  2. Drag & Drop when parent and childs accept drops?
    By gri in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 10:00
  3. Drag and Drop QTableWidget and QTableView
    By scorpion11 in forum Qt Programming
    Replies: 5
    Last Post: 8th April 2008, 10:33
  4. Replies: 7
    Last Post: 8th September 2006, 17:19
  5. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 17:41

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.