I have a DragDropScene : public QgraphicsScene with drag processing like this:
void DragDropScene::dragEnterEvent( QGraphicsSceneDragDropEvent *event )
{
if( event->mimeData()->hasFormat( ITEMDRAGMIMETYPE ) )
{
event->acceptProposedAction();
return;
}
event->ignore();
}
void DragDropScene::dragMoveEvent( QGraphicsSceneDragDropEvent *event )
{
dragEnterEvent( event );
}
void DragDropScene::dragEnterEvent( QGraphicsSceneDragDropEvent *event )
{
QGraphicsScene::dragEnterEvent(event);
if( event->mimeData()->hasFormat( ITEMDRAGMIMETYPE ) )
{
event->acceptProposedAction();
return;
}
event->ignore();
}
void DragDropScene::dragMoveEvent( QGraphicsSceneDragDropEvent *event )
{
dragEnterEvent( event );
}
To copy to clipboard, switch view to plain text mode
On this scene I have item with drag processing like this:
void ConnectableItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
qDebug() << event->pos();
event->ignore();
}
void ConnectableItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{
dragEnterEvent(event);
}
void ConnectableItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
qDebug() << event->pos();
event->ignore();
}
void ConnectableItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{
dragEnterEvent(event);
}
To copy to clipboard, switch view to plain text mode
In constructor of ConnectableItem I have call of
setAcceptDrops( true );
setAcceptDrops( true );
To copy to clipboard, switch view to plain text mode
All works except drag processing in ConnectableItem. Functions do not call.
Added after 1 56 minutes:
Almost solved. Call to QGraphicsScene::dragMoveEvent(event); needed in DragDropScene::dragMoveEvent(...) with code processing event separetly from dragMoveEvent(). I receive events in ConnectableItem::dragMoveEvent(). But I cannot ignore() them. They are always accepted.
Bookmarks