當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QMimeData方法代碼示例

本文整理匯總了Python中PyQt5.QtCore.QMimeData方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QMimeData方法的具體用法?Python QtCore.QMimeData怎麽用?Python QtCore.QMimeData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtCore的用法示例。


在下文中一共展示了QtCore.QMimeData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: mouseMoveEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mouseMoveEvent(self, event):
        if (event.buttons() == Qt.LeftButton and
                (event.modifiers() == Qt.ControlModifier or
                         event.modifiers() == Qt.ShiftModifier)):
            mime_data = QMimeData()
            mime_data.setText(PageWidget.DRAG_MAGIC)

            drag = QDrag(self)
            drag.setMimeData(mime_data)
            drag.setPixmap(self.grab(self.rect()))

            if event.modifiers() == Qt.ControlModifier:
                drag.exec_(Qt.MoveAction)
            else:
                drag.exec_(Qt.CopyAction)

            event.accept()
        else:
            event.ignore() 
開發者ID:FrancescoCeruti,項目名稱:linux-show-player,代碼行數:21,代碼來源:cue_widget.py

示例2: __init__

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def __init__(self, parent=None):
        super(DragButton, self).__init__(parent)

    # def mouseMoveEvent(self, event):
        # self.startDrag()
        # QtWidgets.QToolButton.mouseMoveEvent(self, event)

    # def startDrag(self):
        # if self.icon().isNull():
        #     return
        # data = QtCore.QByteArray()
        # stream = QtCore.QDataStream(data, QtCore.QIODevice.WriteOnly)
        # stream << self.icon()
        # mimeData = QtCore.QMimeData()
        # mimeData.setData("application/x-equipment", data)
        # drag = QtGui.QDrag(self)
        # drag.setMimeData(mimeData)
        # pixmap = self.icon().pixmap(24, 24)
        # drag.setHotSpot(QtCore.QPoint(12, 12))
        # drag.setPixmap(pixmap)
        # drag.exec_(QtCore.Qt.CopyAction) 
開發者ID:jjgomera,項目名稱:pychemqt,代碼行數:23,代碼來源:widgets.py

示例3: mouseMoveEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mouseMoveEvent(self, mouseEvent):
        """
        Executed when the mouse if moved while a button is being pressed.
        :type mouseEvent: QMouseEvent
        """
        if mouseEvent.buttons() & QtCore.Qt.LeftButton:
            if Item.ConceptNode <= self.item < Item.InclusionEdge:
                distance = (mouseEvent.pos() - self.startPos).manhattanLength()
                if distance >= QtWidgets.QApplication.startDragDistance():
                    mimeData = QtCore.QMimeData()
                    mimeData.setText(str(self.item.value))
                    drag = QtGui.QDrag(self)
                    drag.setMimeData(mimeData)
                    drag.setPixmap(self.icon().pixmap(60, 40))
                    drag.setHotSpot(self.startPos - self.rect().topLeft())
                    drag.exec_(QtCore.Qt.CopyAction)

        super().mouseMoveEvent(mouseEvent) 
開發者ID:danielepantaleone,項目名稱:eddy,代碼行數:20,代碼來源:palette.py

示例4: mousePressEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mousePressEvent(self, event):

        child = self.childAt(event.pos())
        if not child:
            return

        mimeData = QMimeData()
        mimeData.setText(child.type)

        logging.debug('mousePressEvent() called: {}'.format(event.pos()))
        drag = QDrag(self)
        drag.setPixmap(child.pixmap())
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos() - child.pos())

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            child.close()
        else:
            child.show()
            child.setPixmap(child.pixmap()) 
開發者ID:hANSIc99,項目名稱:Pythonic,代碼行數:22,代碼來源:basictools.py

示例5: mousePressEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mousePressEvent(self, event):
            
        logging.debug('ElementMaster::mousePressEvent() called')
        # uncomment this for debugging purpose
        #self.listChild()

        if event.buttons() != Qt.LeftButton:
            return

        icon = QLabel()

        mimeData = QMimeData()
        mime_text = str(self.row) + str(self.column) + str(self.__class__.__name__)
        mimeData.setText(mime_text)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(self.pixmap)
        drag.setHotSpot(event.pos() - self.rect().topLeft())

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            icon.close()
        else:
            icon.show()
            icon.setPixmap(self.pixmap) 
開發者ID:hANSIc99,項目名稱:Pythonic,代碼行數:27,代碼來源:elementmaster.py

示例6: test_EditorPane_drop_event

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def test_EditorPane_drop_event(qtapp):
    """
    If there's a drop event associated with files, cause them to be passed into
    Mu's existing file loading code.
    """
    ep = mu.interface.editor.EditorPane(None, "baz")
    m = mock.MagicMock()
    ep.open_file = mock.MagicMock()
    ep.open_file.emit = m
    data = QMimeData()
    data.setUrls(
        [
            QUrl("file://test/path.py"),
            QUrl("file://test/path.hex"),
            QUrl("file://test/path.txt"),
        ]
    )
    evt = QDropEvent(
        QPointF(0, 0), Qt.CopyAction, data, Qt.LeftButton, Qt.NoModifier
    )
    ep.dropEvent(evt)
    # Upstream _load will handle invalid file type (.txt).
    assert m.call_count == 3 
開發者ID:mu-editor,項目名稱:mu,代碼行數:25,代碼來源:test_editor.py

示例7: mouseMoveEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mouseMoveEvent(self, event):
		super(CodeUIItem, self).mouseMoveEvent(event)
		if self.isSelected():
			# update target positions of all dragging items
			from UIManager import UIManager
			scene = UIManager.instance().getScene()
			for uname, node in scene.itemDict.items():
				if node.isSelected():
					node.targetPos = QtCore.QPointF(node.pos().x(), node.pos().y())

		if event.buttons().__int__() & QtCore.Qt.MidButton or event.buttons().__int__() & QtCore.Qt.RightButton:
			print('event button:', event.buttons().__int__())
			drag = QtWidgets.QDrag(event.widget())
			mime = QtCore.QMimeData()
			mime.setText(self.uniqueName)
			drag.setMimeData(mime)
			drag.exec()
			#self.setCursor(QtCore.Qt.OpenHandCursor) 
開發者ID:league1991,項目名稱:CodeAtlasSublime,代碼行數:20,代碼來源:CodeUIItem.py

示例8: mimeData

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mimeData(self, indexes):
        mimeData = QtCore.QMimeData()
        encodedData = QtCore.QByteArray()

        stream = QtCore.QDataStream(encodedData, QtCore.QIODevice.WriteOnly)

        for index in indexes:
            if index.isValid():
                pixmap = QtGui.QPixmap(self.data(index, Qt.UserRole))
                stream << pixmap

        mimeData.setData('image/x-tile-piece', encodedData)
        return mimeData 
開發者ID:aboood40091,項目名稱:Miyamoto,代碼行數:15,代碼來源:puzzle.py

示例9: mouseMoveEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mouseMoveEvent(self, e):

        if e.buttons() != Qt.RightButton: # 隻操作右鍵事件
            return

        mimeData = QMimeData()

        drag = QDrag(self)  # 創建一個QDrag對象,用來傳輸MIME-based數據
        drag.setMimeData(mimeData)
        drag.setHotSpot(e.pos() - self.rect().topLeft())

        dropAction = drag.exec_(Qt.MoveAction) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:14,代碼來源:dragbutton.py

示例10: mousePressEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mousePressEvent(self, event):
        # retrieve the label 
        child = self.childAt(event.pos())
        
        if not child:
            return
        
        self.controller.mode = 'selection'
        # update the creation mode to the appropriate subtype
        self.controller.creation_mode = child.subtype
        
        pixmap = QPixmap(child.pixmap().scaled(
                                            QSize(50, 50), 
                                            Qt.KeepAspectRatio,
                                            Qt.SmoothTransformation
                                            ))

        mime_data = QtCore.QMimeData()
        mime_data.setData('application/x-dnditemdata', QtCore.QByteArray())

        drag = QtGui.QDrag(self)
        drag.setMimeData(mime_data)
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos() - child.pos() + QPoint(-3, -10))

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            child.close()
        else:
            child.show() 
開發者ID:afourmy,項目名稱:pyNMS,代碼行數:31,代碼來源:site_panel.py

示例11: mousePressEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mousePressEvent(self, event):
        # retrieve the label 
        child = self.childAt(event.pos())
        if not child:
            return
        
        self.controller.mode = 'selection'
        # update the creation mode to the appropriate subtype
        self.controller.creation_mode = child.subtype
        # we change the view if necessary:
        # if it is a site, we switch the site view
        # if it is anything else and we are in the site view, we switch 
        # to the network view
        if child.subtype == 'site':
            self.project.show_site_view()
        else:
            if self.project.view_type == 'site':
                self.project.show_network_view()
        
        pixmap = QPixmap(child.pixmap().scaled(
                                            QSize(50, 50), 
                                            Qt.KeepAspectRatio,
                                            Qt.SmoothTransformation
                                            ))

        mime_data = QtCore.QMimeData()
        mime_data.setData('application/x-dnditemdata', QtCore.QByteArray())

        drag = QtGui.QDrag(self)
        drag.setMimeData(mime_data)
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos() - child.pos() + QPoint(-3, -10))

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            child.close()
        else:
            child.show() 
開發者ID:afourmy,項目名稱:pyNMS,代碼行數:39,代碼來源:network_node_creation_panel.py

示例12: to_clipboard

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def to_clipboard(text):
    mime = QMimeData()
    mime.setText(text)
    board = QGuiApplication.clipboard()
    board.setMimeData(mime, mode=QClipboard.Clipboard) 
開發者ID:Thomasedv,項目名稱:Grabber,代碼行數:7,代碼來源:utilities.py

示例13: mousePressEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mousePressEvent(self, event):

        child = self.childAt(event.pos())
        if not child:
            return

        pixmap = QPixmap(child.pixmap())

        mimeData = QMimeData()
        mimeData.setText(child.type)

        drag = QDrag(self)
        drag.setPixmap(child.pixmap())
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos() - child.pos())

        tempPixmap = QPixmap(pixmap)
        painter = QPainter()
        painter.begin(tempPixmap)
        painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127))
        painter.end()

        child.setPixmap(tempPixmap)

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            child.close()
        else:
            child.show()
            child.setPixmap(pixmap) 
開發者ID:hANSIc99,項目名稱:Pythonic,代碼行數:31,代碼來源:connectivitytools.py

示例14: mousePressEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mousePressEvent(self, event):
        
        logging.debug('DropBox::mousePressEvent() called: {}'.format(event.pos()))
        try:
            mimeData = QMimeData()
            mimeData.setText(self.type)
            # load config into memory tmp_config of storabar
            self.parent.tmp_config = self.config
            self.parent.tmp_element = self
            # push config to active workingarea
            self.parent.loadConfig() 
        except Exception as e:
            logging.error('DropBox::mousePressEvent() Exception caught: {}'.format(str(e)))
            return

        drag = QDrag(self)
        drag.setHotSpot(event.pos())
        drag.setPixmap(self.label.pixmap())
        drag.setMimeData(mimeData)

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            self.close()
        else:
            self.show()
            self.label.setPixmap(self.label.pixmap())
            logging.debug('DropBox::mousePressEvent() dropped') 
開發者ID:hANSIc99,項目名稱:Pythonic,代碼行數:28,代碼來源:dropbox.py

示例15: mouseMoveEvent_xxx

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QMimeData [as 別名]
def mouseMoveEvent_xxx(self, e):
        mimeData = QtCore.QMimeData()
        drag = QDrag(self)
        drag.setMimeData(mimeData)

        # pixmap = QPixmap()
        # drag.setPixmap(pixmap)

        # drag.setHotSpot(e.pos())

        # QTreeWidget.mouseMoveEvent(self,e)
        drag.exec_(QtCore.Qt.MoveAction) 
開發者ID:PyQt5,項目名稱:PyQt,代碼行數:14,代碼來源:Custom_DND_image.py


注:本文中的PyQt5.QtCore.QMimeData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。