Results 1 to 3 of 3

Thread: Drag/Drop: Drop indicator doesn't change for drags between QListView and QTableView

  1. #1
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Drag/Drop: Drop indicator doesn't change for drags between QListView and QTableView

    When dragging between a QListView and a QTableView the drop indicator does not change, so the QTableView::dropEvent() is never called when releasing the mouse button. But, debugging code in the QTableView::dragEnterEvent() states:
    • DropAction: Qt::MoveAction
    • DragDropMode: QAbstractItemView:: DropOnly
    • DropIndicatorShown: TRUE
    • DragDropOverwriteMode: TRUE
    I have a QStandardModel that services both a QGraphicsScene/View and the QTableView (the table view is filled via QSortFilterProxyModel class. Drops into the QGraphicsScene work fine.

    Any ideas about what I can do to get the QTableView to show a drop indicator and allow dropEvent() to be called?

    For reference, this is my table view ctor.
    Qt Code:
    1. SheetView::SheetView( QWidget* pParent ) : QTableView( pParent )
    2. {
    3. setSelectionMode( QAbstractItemView::SingleSelection );
    4. setAcceptDrops( true );
    5. setDropIndicatorShown( true );
    6. setDragDropMode( QAbstractItemView::DropOnly );
    7. setDragDropOverwriteMode( true );
    8. setSelectionBehavior( QAbstractItemView::SelectRows );
    9. }
    To copy to clipboard, switch view to plain text mode 
    Qt Commercial 4.6.2
    Windows XP SP3

  2. #2
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drag/Drop: Drop indicator doesn't change for drags between QListView and QTableVi

    Still no drop indicator. This seems like such a simple operation but I still can't figure out why it's not working.

    I thought that using a proxy model might be causing my problems but the proxy model calls setSupportedDragActions( Qt::CopyAction | Qt::MoveAction ) in the constructor which should handle the model side of things. At the end of the proxy ctor the supported actions are:
    • Drop: Qt::CopyAction
    • Drag: Qt::CopyAction | Qt::MoveAction

    Here is my dragEnterEvent.

    Qt Code:
    1. void SheetView::dragEnterEvent( QDragEnterEvent* pEvent )
    2. {
    3. if ( pEvent->mimeData()->hasFormat( MY_MIMETYPE ) )
    4. pEvent->acceptProposedAction();
    5. else
    6. pEvent->setDropAction( Qt::IgnoreAction );
    7. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drag/Drop: Drop indicator doesn't change for drags between QListView and QTableVi

    SOLVED:

    I guess if I would reimplement all the required functions I would not have this trouble. The default implementation of dragMoveEvent() ignores events. Overridding this function fixes this problem.

    Qt Code:
    1. void SheetView::dragMoveEvent( QDragMoveEvent* pEvent )
    2. {
    3. if ( !pEvent->mimeData()->hasFormat( MY_MIMETYPE ) )
    4. {
    5. pEvent->ignore();
    6. return;
    7. }
    8.  
    9. pEvent->accept();
    10. }
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to mclark for this useful post:

    ComServant (8th July 2013)

Similar Threads

  1. Replies: 0
    Last Post: 4th May 2010, 10:24
  2. Drag and Drop from QListView to QGraphicsView
    By NoRulez in forum Qt Programming
    Replies: 0
    Last Post: 20th August 2009, 14:26
  3. Drag and drop indicator
    By iswm in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2007, 18:58
  4. qlistview drag&drop problem
    By moowy in forum Qt Programming
    Replies: 8
    Last Post: 13th October 2006, 14:49
  5. Problem with drag&drop in qlistview
    By mambo in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2006, 16:14

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.