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.
Code:
{
setAcceptDrops( true );
setDropIndicatorShown( true );
setDragDropOverwriteMode( true );
}
Qt Commercial 4.6.2
Windows XP SP3
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.
Code:
{
if ( pEvent->mimeData()->hasFormat( MY_MIMETYPE ) )
pEvent->acceptProposedAction();
else
pEvent->setDropAction( Qt::IgnoreAction );
}
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.
Code:
{
if ( !pEvent->mimeData()->hasFormat( MY_MIMETYPE ) )
{
pEvent->ignore();
return;
}
pEvent->accept();
}