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


Python QDrag.exec_方法代碼示例

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


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

示例1: mousePressEvent

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
 def mousePressEvent(self, event):
     mime = QMimeData()
     itemData = QByteArray()
     mime.setData('application/x-dnditemdata', itemData)
     drag = QDrag(self)
     drag.setMimeData(mime)
     drag.exec_(Qt.MoveAction)
開發者ID:thesmartwon,項目名稱:OpenChess-Python,代碼行數:9,代碼來源:tests.py

示例2: mouseMoveEvent

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
    def mouseMoveEvent(self, event):
        if QLineF(QPointF(event.screenPos()), QPointF(event.buttonDownScreenPos(Qt.LeftButton))).length() < QApplication.startDragDistance():
            return

        drag = QDrag(event.widget())
        mime = QMimeData()
        drag.setMimeData(mime)

        ColorItem.n += 1
        if ColorItem.n > 2 and qrand() % 3 == 0:
            image = QImage(':/images/head.png')
            mime.setImageData(image)
            drag.setPixmap(QPixmap.fromImage(image).scaled(30,40))
            drag.setHotSpot(QPoint(15, 30))
        else:
            mime.setColorData(self.color)
            mime.setText("#%02x%02x%02x" % (self.color.red(), self.color.green(), self.color.blue()))

            pixmap = QPixmap(34, 34)
            pixmap.fill(Qt.white)

            painter = QPainter(pixmap)
            painter.translate(15, 15)
            painter.setRenderHint(QPainter.Antialiasing)
            self.paint(painter, None, None)
            painter.end()

            pixmap.setMask(pixmap.createHeuristicMask())

            drag.setPixmap(pixmap)
            drag.setHotSpot(QPoint(15, 20))

        drag.exec_()
        self.setCursor(Qt.OpenHandCursor)
開發者ID:CarlosAndres12,項目名稱:pyqt5,代碼行數:36,代碼來源:dragdroprobot.py

示例3: mouseMoveEvent

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
 def mouseMoveEvent(self, event):
     """
     Protected method to handle mouse move events.
     
     @param event reference to the mouse move event (QMouseEvent)
     """
     if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
        (event.pos() - self.__dragStartPos).manhattanLength() > \
             QApplication.startDragDistance():
         drag = QDrag(self)
         mimeData = QMimeData()
         index = self.tabAt(event.pos())
         mimeData.setText(self.tabText(index))
         mimeData.setData("action", b"tab-reordering")
         mimeData.setData("tabbar-id", str(id(self)).encode("utf-8"))
         mimeData.setData(
             "source-index",
             QByteArray.number(self.tabAt(self.__dragStartPos)))
         mimeData.setData(
             "tabwidget-id",
             str(id(self.parentWidget())).encode("utf-8"))
         drag.setMimeData(mimeData)
         if event.modifiers() == Qt.KeyboardModifiers(Qt.ShiftModifier):
             drag.exec_(Qt.DropActions(Qt.CopyAction))
         elif event.modifiers() == Qt.KeyboardModifiers(Qt.NoModifier):
             drag.exec_(Qt.DropActions(Qt.MoveAction))
     super(TabBar, self).mouseMoveEvent(event)
開發者ID:paulmadore,項目名稱:Eric-IDE,代碼行數:29,代碼來源:Tabview.py

示例4: startDrag

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
    def startDrag(self):
        self.mimeData = MimeData()
        self.mimeData.dataRequested.connect(self.createData, Qt.DirectConnection)

        drag = QDrag(self)
        drag.setMimeData(self.mimeData)
        drag.setPixmap(QPixmap(':/images/drag.png'))
        drag.exec_(Qt.CopyAction)
開發者ID:Axel-Erfurt,項目名稱:pyqt5,代碼行數:10,代碼來源:delayedencoding.py

示例5: newComponentButtonMousePress

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
	def newComponentButtonMousePress(self, componentType, event):
		self.tool = Tool.NewComponent
		self.mouseState = MouseState.Dragging
		self.newComponentType = componentType
		
		newComponentDrag = QDrag(self.view)
		newComponentDrag.setHotSpot(QPoint(self.view.ui.circuitDiagram.blockSideLength / 2, self.view.ui.circuitDiagram.blockSideLength / 2))
		newComponentDrag.setMimeData(QMimeData())
		newComponentDrag.setPixmap(QPixmap(self.view.ui.circuitDiagram.componentTypeToImageName(componentType)).scaled(self.view.ui.circuitDiagram.blockSideLength, self.view.ui.circuitDiagram.blockSideLength))
		newComponentDrag.exec_(Qt.MoveAction)
開發者ID:bandienkhamgalan,項目名稱:flappyeagle,代碼行數:12,代碼來源:MainController.py

示例6: __dragSnapshot

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
 def __dragSnapshot(self):
     """
     Private slot handling the dragging of the preview picture.
     """
     drag = QDrag(self)
     mimeData = QMimeData()
     mimeData.setImageData(self.__snapshot)
     drag.setMimeData(mimeData)
     drag.setPixmap(self.preview.pixmap())
     drag.exec_(Qt.CopyAction)
開發者ID:pycom,項目名稱:EricShort,代碼行數:12,代碼來源:SnapWidget.py

示例7: dragFile

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
def dragFile(widget, filename, icon=None, dropactions=Qt.CopyAction):
    """Starts dragging the given local file from the widget."""
    if icon is None or icon.isNull():
        icon = QFileIconProvider().icon(QFileInfo(filename))
    drag = QDrag(widget)
    data = QMimeData()
    data.setUrls([QUrl.fromLocalFile(filename)])
    drag.setMimeData(data)
    drag.setPixmap(icon.pixmap(32))
    drag.exec_(dropactions)
開發者ID:AlexSchr,項目名稱:frescobaldi,代碼行數:12,代碼來源:drag.py

示例8: mouseMoveEvent

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
 def mouseMoveEvent(self, e):
     modifiers = QApplication.keyboardModifiers()
     if modifiers == Qt.ControlModifier:
         mimeData = QMimeData()
         drag = QDrag(e.widget())
         mimeData.setText("node")
         drag.setMimeData(mimeData)
         drag.exec_(Qt.MoveAction)
         self.ungrabMouse()
     if self.edgeInConstruction != None:
         self.edgeInConstruction.obsUpdate(e.scenePos())
開發者ID:MatthieuDien,項目名稱:DotEd,代碼行數:13,代碼來源:node.py

示例9: mousePressEvent

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
    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_()
開發者ID:Cyber-Forensic,項目名稱:urh,代碼行數:15,代碼來源:SignalFrameController.py

示例10: mouseMoveEvent

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:
            index = self._findEventIndex(event)
            if self._maybeDragPosition is not None:
                if ((event.pos() - self._maybeDragPosition).manhattanLength()
                        < QApplication.startDragDistance()):
                        return
                # TODO: needs ordering or not?
                glyphList = " ".join(
                    glyph.name for glyph in self.getSelectedGlyphs())
                drag = QDrag(self)
                mimeData = QMimeData()
                mimeData.setText(glyphList)
                drag.setMimeData(mimeData)

                drag.exec_()
                self._maybeDragPosition = None
                event.accept()
                return
            if index == self._lastSelectedCell:
                return

            modifiers = event.modifiers()
            event.accept()
            if index is None:
                if not (modifiers & Qt.ControlModifier or
                        modifiers & Qt.ShiftModifier):
                    self.selection = set()
                self._lastSelectedCell = index
                return
            if modifiers & Qt.ControlModifier:
                if index in self._selection and index in self._oldSelection:
                    selection = self.selection
                    selection.remove(index)
                    self.selection = selection
                elif (index not in self._selection and
                      index not in self._oldSelection):
                    selection = self.selection
                    selection.add(index)
                    self.selection = selection
            elif modifiers & Qt.ShiftModifier:
                newSelection = self._linearSelection(index)
                if newSelection is not None:
                    self.selection = newSelection
            else:
                self.selection = {index}
            self.lastSelectedCell = index
        else:
            super(GlyphCollectionWidget, self).mouseMoveEvent(event)
開發者ID:adrientetar,項目名稱:trufont,代碼行數:51,代碼來源:glyphCollectionView.py

示例11: maybeExecuteDrag

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
    def maybeExecuteDrag(self, event):
        if self._maybeDragPosition is None:
            return False
        if (event.localPos() - self._maybeDragPosition).manhattanLength() \
                < QApplication.startDragDistance():
            return False

        drag = QDrag(self)
        glyphs = self.glyphsForIndexes(self.selection())
        mimeData = GlyphsMimeData()
        mimeData.setGlyphs(glyphs)
        drag.setMimeData(mimeData)
        drag.exec_()
        self._maybeDragPosition = None
        return True
開發者ID:adrientetar,項目名稱:defconQt,代碼行數:17,代碼來源:glyphCellView.py

示例12: mouseMoveEvent

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
 def mouseMoveEvent(self, event):
     super().mouseMoveEvent(event)
     if (
             event.buttons() == Qt.LeftButton and 
             self.left_start is not None and 
             (event.globalPos() - self.left_start).manhattanLength() >=
                 QApplication.startDragDistance()
             ):
         self.drag_start.emit()
         mime = QMimeData()
         drag = QDrag(self)
         drag.setMimeData(mime)
         self.left_start = None
         drag.exec_(Qt.MoveAction)
         self.drag_stop.emit()
開發者ID:Rendaw,項目名稱:ptadventure,代碼行數:17,代碼來源:qtwrapper.py

示例13: mousePressEvent

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
    def mousePressEvent(self, event):
        child = self.childAt(event.pos())
        if not child:
            return

        pixmap = QPixmap(child.pixmap())

        itemData = QByteArray()
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)
        dataStream << pixmap << QPoint(event.pos() - child.pos())

        mimeData = QMimeData()
        mimeData.setData('application/x-dnditemdata', itemData)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        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:Axel-Erfurt,項目名稱:pyqt5,代碼行數:34,代碼來源:draggableicons.py

示例14: startDrag

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
 def startDrag(self):
     image = self.image()
     data = QMimeData()
     data.setImageData(image)
     drag = QDrag(self)
     drag.setMimeData(data)
     if max(image.width(), image.height()) > 256:
         image = image.scaled(QSize(256, 256), Qt.KeepAspectRatio, Qt.SmoothTransformation)
     p = QPainter()
     p.begin(image)
     p.setCompositionMode(QPainter.CompositionMode_DestinationIn)
     p.fillRect(image.rect(), QColor(0, 0, 0, 160))
     p.end()
     pixmap = QPixmap.fromImage(image)
     drag.setPixmap(pixmap)
     drag.setHotSpot(pixmap.rect().center())
     drag.exec_(Qt.CopyAction)
開發者ID:19joho66,項目名稱:frescobaldi,代碼行數:19,代碼來源:imageviewer.py

示例15: mouseMoveEvent

# 需要導入模塊: from PyQt5.QtGui import QDrag [as 別名]
# 或者: from PyQt5.QtGui.QDrag import exec_ [as 別名]
 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)
開發者ID:HappyJamesL,項目名稱:pyqtlearn,代碼行數:10,代碼來源:dragdrop.py


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