forked from morevnaproject-org/papagayo-ng
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSceneWithDrag.py
More file actions
24 lines (20 loc) · 786 Bytes
/
SceneWithDrag.py
File metadata and controls
24 lines (20 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
# -*- coding: ISO-8859-1 -*-
import PySide6.QtWidgets as QtWidgets
from PySide6 import QtGui
class SceneWithDrag(QtWidgets.QGraphicsScene):
def dragEnterEvent(self, e):
e.acceptProposedAction()
def dropEvent(self, e):
# find item at these coordinates
item = self.itemAt(e.scenePos(), QtGui.QTransform())
if item:
if item.setAcceptDrops:
# pass on event to item at the coordinates
item.dropEvent(e)
try:
item.dropEvent(e)
except RuntimeError:
pass # This will suppress a Runtime Error generated when dropping into a widget with no MyProxy
def dragMoveEvent(self, e):
e.acceptProposedAction()