示例#1
0
文件: table.py 项目: rpanerai/Eddy
    def startDrag(self, supportedActions):
        # We reimplement this to visualize a tooltip instead of entire rows while dragging.

        rows = self.selectionModel().selectedRows()
        data = self.model().mimeData(rows)

        label = QLabel(
            str(len(rows)) + " items" if len(rows) > 1 else "1 item")
        # Use QPalette.ColorRole?
        label.setStyleSheet(
            "font-weight: bold; color : white; background-color : black; border: 1px solid grey"
        )
        pixmap = label.grab()
        pixmap.rect().adjust(10, 10, 0, 0)

        drag = QDrag(self)
        drag.setPixmap(pixmap)
        # drag.setDragCursor(pixmap, Qt.CopyAction)
        drag.setMimeData(data)
        drag.setHotSpot(pixmap.rect().center())
        drag.exec_(Qt.CopyAction)