Python PyQt5.QtCore 模块,QMimeData() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用PyQt5.QtCore.QMimeData()

项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def mousePressEvent(self, event):
        hotSpot = event.pos()

        mimeData = QMimeData()
        mimeData.setText(self.text())
        mimeData.setData('application/x-hotspot',
                '%d %d' % (hotSpot.x(), hotSpot.y()))

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(hotSpot)

        dropAction = drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction)

        if dropAction == Qt.MoveAction:
            self.close()
            self.update()
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def mousePressEvent(self, event):
        hotSpot = event.pos()

        mimeData = QMimeData()
        mimeData.setText(self.text())
        mimeData.setData('application/x-hotspot',
                '%d %d' % (hotSpot.x(), hotSpot.y()))

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(hotSpot)

        dropAction = drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction)

        if dropAction == Qt.MoveAction:
            self.close()
            self.update()
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def mousePressEvent(self, event):
        hotSpot = event.pos()

        mimeData = QMimeData()
        mimeData.setText(self.text())
        mimeData.setData('application/x-hotspot',
                '%d %d' % (hotSpot.x(), hotSpot.y()))

        pixmap = QPixmap(self.size())
        self.render(pixmap)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(hotSpot)

        dropAction = drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction)

        if dropAction == Qt.MoveAction:
            self.close()
            self.update()
项目:incubator-senssoft-userale-pyqt5    作者:apache    | 项目源码 | 文件源码
def mouseMoveEvent(self, e):

        if e.buttons() != Qt.RightButton:
            return

        mimeData = QMimeData()

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(e.pos() - self.rect().topLeft())

        dropAction = drag.exec_(Qt.MoveAction)
项目:PyQt5-reorderable-list-model    作者:d1vanov    | 项目源码 | 文件源码
def mimeData(self, indexes):
        mimedata = QtCore.QMimeData()
        encoded_data = QtCore.QByteArray()
        stream = QtCore.QDataStream(encoded_data, QtCore.QIODevice.WriteOnly)
        for index in indexes:
            if index.isValid():
                text = self.data(index, 0)
        stream << QtCore.QByteArray(text.encode('utf-8'))
        mimedata.setData('application/vnd.treeviewdragdrop.list', encoded_data)
        return mimedata
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def mimeData(self, indexes):
        """
        This function is called by QT each time a drag operation is
        initiated, to serialize the data associated with the
        dragged item. However, QT doesn't know how to serialize a Shape
        or a Layer, so it throws an error ... since we handle Drag & Drop
        internally, we don't need any serialization, so we subclass
        the function and return nothing (trick to avoid errors).
        """
        mimeData = QtCore.QMimeData()
        #mimeData.setData("application/x-qabstractitemmodeldatalist", "")
        mimeData.setData("application/x-qstandarditemmodeldatalist", "")

        return mimeData
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def pop(self, row, parent=QtCore.QModelIndex()):
        self.beginRemoveRows(parent, row, row + 1)
        self.rows.pop(row)
        self.endRemoveRows()

        # def mimeTypes(self):
        # types = QtCore.QStringList()
        # types.append('vqt/row')
        # return types

        # def mimeData(self, idx):
        # nodes = [ self.rows[i.row()][-1] for i in idx ]
        # mdata = QtCore.QMimeData()
        # mdata.setData('vqt/rows',json.dumps(nodes))
        # return mdata
项目:opcua-widgets    作者:FreeOpcUa    | 项目源码 | 文件源码
def mimeData(self, idxs):
        mdata = QMimeData()
        nodes = []
        for idx in idxs:
            item = self.itemFromIndex(idx)
            if item:
                node = item.data(Qt.UserRole)
                if node:
                    nodes.append(node.nodeid.to_string())
        mdata.setText(", ".join(nodes))
        return mdata
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def mimeData(self, indexes):
        data = ''
        for index in indexes:
            parent_item = self.getItem(index.parent())
            if parent_item == self.rootItem:
                data += "{0},{1},{2}/".format(index.row(), index.column(), -1)
            else:
                data += "{0},{1},{2}/".format(index.row(), index.column(), self.rootItem.index_of(parent_item))
        mime_data = QMimeData()
        mime_data.setText(data)
        return mime_data
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def mimeData(self, indexes):
        data = "PLabels:"
        data += "/".join([str(index.row()) for index in indexes])
        mime_data = QMimeData()
        mime_data.setText(data)
        return mime_data
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.drag_started.emit(self.mapToParent(event.pos()))
            drag = QDrag(self)
            mimeData = QMimeData()
            mimeData.setText("Move Signal")
            pixmap = QPixmap(self.rect().size())
            self.render(pixmap, QPoint(), QRegion(self.rect()))
            drag.setPixmap(pixmap)

            drag.setMimeData(mimeData)

            drag.exec_()