내가 아는 한 QGraphicsScene 자체에서는 구현되지 않습니다. 당신이를 QGraphicsView 또는 QGraphicsScene에서 자신의 클래스를 파생하고 과부하해야합니다
class MyGraphicsView : public QGraphicsView
{
Q_OBJECT;
protected:
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseMoveEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
...
private:
QGraphicsItem *currentDraggedItem;
};
를 QGraphicsView보기/창 작품을 제공 QGraphicsScene이 장면 좌표와 함께 작동하면서 조정합니다.
추가 코드는 같은 :
void MyGraphicsView::mousePressEvent(QMouseEvent* event)
{
currentDraggedItem = itemAt(event->pos());
QGraphicsView::mousePressEvent(event);
}
void MyGraphicsView::mouseReleaseEvent(QMouseEvent* event)
{
QGraphicsItem *foundItem = itemAt(event->pos());
if(foundItem && currentDraggedItem &&
foundItem != currentDraggedItem)
{
// Handle DragDrop Here
}
QGraphicsView::mouseReleaseEvent(event);
}
이 하나 QGaphicsScene에 대한 작업을 수행합니다. 두 개가있는 경우 - 둘 다 서로를 알아야하며 하나의 QGraphicsView에서 다른 QGraphicsView로 좌표를 변환해야합니다. mapTo ...()를 사용하여.
[다음 예] (http://qt-project.org/doc/qt-4.8/examples-draganddrop.html)는 약간의 도움이 될 것입니다. – thuga