Results 1 to 2 of 2

Thread: Derived dropMimeData never called

  1. #1
    Join Date
    Jul 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Derived dropMimeData never called

    Hi,

    I've followed the drag and drop documentation on how to implement drag and drop in a view. However, I can't get it to work.

    I have a QWidget which has a QTreeView inside of it. On the QTreeView I set:
    Qt Code:
    1. tree_view->setSelectionMode(QAbstractItemView::ExtendedSelection);
    2.  
    3. // Enable drag and drop
    4. tree_view->setDragEnabled(true);
    5. tree_view->setAcceptDrops(true);
    6. tree_view->setDropIndicatorShown(true);
    7. tree_view->setDragDropMode(QAbstractItemView::DragDrop);
    To copy to clipboard, switch view to plain text mode 

    The tree view has a proxy model which has a source model that i've derived from QAbstractItemModel. In my derived model class I've implemented:
    Qt Code:
    1. Qt::ItemFlags flags(const QModelIndex &index) const // Returns Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
    2. Qt::DropActions supportedDragActions() const; // Returns Qt::CopyAction | Qt::MoveAction;
    3. QStringList mimeTypes() const;
    4. QMimeData *mimeData(const QModelIndexList &indicies) const;
    5. bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
    To copy to clipboard, switch view to plain text mode 

    When I try to drag an item mimeData() gets called and seems to encode the data correctly. However, dropMimeData() is never called after that. When I attempt to drag an item, I never see any indicator either. I can't work out what is missing. Does anyone have any idea of what I'm missing?

    Regards,
    davsa
    Last edited by davsa; 17th July 2012 at 08:24.

  2. #2
    Join Date
    Aug 2012
    Posts
    11
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Derived dropMimeData never called

    Did you ever figure this out? I'm having the exact same problem. The funny thing is, it was working a month ago. I don't think I changed anything in those two files, but when I tried it just now it didn't work. I did upgrade from Qt 4.5 to Qt 4.8, but I don't think that would break it.

    Edit: Actually, my problem isn't identical. It's mimeTypes that is getting called when an object is dragged. mimeData never gets called.
    Last edited by ImperialPenguin; 18th August 2012 at 05:27.

Similar Threads

  1. QwtPlot derived class
    By Marco Trapanese in forum Qwt
    Replies: 15
    Last Post: 4th December 2012, 10:05
  2. QPushButtons and Data, Not Derived
    By tescrin in forum Qt Programming
    Replies: 2
    Last Post: 5th July 2012, 20:49
  3. Replies: 1
    Last Post: 24th October 2010, 02:40
  4. Can not cast into the derived class from QScrollBar
    By learning_qt in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2008, 10:23
  5. rtti() of derived class
    By quickNitin in forum Newbie
    Replies: 4
    Last Post: 8th October 2006, 14:20

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.