MCPcopy Index your code
hub / github.com/PyQt5/PyQt / startDrag

Method startDrag

QGraphicsView/DragGraphics.py:42–56  ·  view source on GitHub ↗
(self, supportedActions)

Source from the content-addressed store, hash-verified

40 self.setViewMode(QListWidget.IconMode)
41
42 def startDrag(self, supportedActions):
43 items = self.selectedItems()
44 if not items:
45 return
46 # 这里就简单的根据名字提示来传递数据了,实际上可以传递任意数据
47 data = QMimeData()
48 data.setData('application/node-items',
49 json.dumps([item.toolTip() for item in items]).encode())
50 # 这里简单显示第一个缩略图
51 pixmap = items[0].icon().pixmap(36, 36)
52 drag = QDrag(self)
53 drag.setMimeData(data)
54 drag.setPixmap(pixmap)
55 drag.setHotSpot(pixmap.rect().center())
56 drag.exec_(supportedActions)
57
58
59class GraphicsView(QGraphicsView):

Callers

nothing calls this directly

Calls 4

pixmapMethod · 0.80
setDataMethod · 0.45
iconMethod · 0.45
setPixmapMethod · 0.45

Tested by

no test coverage detected