当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QDrag类代码示例

本文整理汇总了Python中PyQt5.QtGui.QDrag的典型用法代码示例。如果您正苦于以下问题:Python QDrag类的具体用法?Python QDrag怎么用?Python QDrag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QDrag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mousePressEvent

 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,代码行数:7,代码来源:tests.py

示例2: mouseMoveEvent

 def mouseMoveEvent(self, e):
     '''
     Luo ratapalsata Mime tiedot, kun sitä liikuttaa
     '''
     mimeData = QMimeData()
     drag = QDrag(e.widget())
     drag.setMimeData(mimeData)
     self.scene.valittu = self
     dropAction = drag.exec_(Qt.MoveAction)
开发者ID:OssiGalkin,项目名称:Pienoisrautatie,代码行数:9,代码来源:PJRRatapala.py

示例3: mousePressEvent

 def mousePressEvent(self, me):
     if me.button() == Qt.LeftButton:
         child = self.find_label()
         if child != None:
             mime_data = QMimeData()
             mime_data.setData('text/plain', child.get_text())
             drag = QDrag(self)
             drag.setMimeData(mime_data)
             #drag.setHotSpot(child.pos())
             drag_action = drag.exec_(Qt.CopyAction | Qt.MoveAction)
开发者ID:jhavstad,项目名称:model_runner,代码行数:10,代码来源:PyQtDnd.py

示例4: mouseMoveEvent

 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,代码行数:11,代码来源:node.py

示例5: newComponentButtonMousePress

	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,代码行数:10,代码来源:MainController.py

示例6: mouseMoveEvent

 def mouseMoveEvent(self, event):
     if not event.buttons() and Qt.LeftButton:
         return
     distance = (event.pos() - self.start_mouse_drag).manhattanLength()
     if distance < QApplication.startDragDistance():
         return
     item = self.selectedItems()[0]
     text = "<row>" + str(item.row()) + "<row>" + "<col>" + str(item.column()) + "<col>" + "<text>" + str(item.text()) + "<text>"
     print(text)
     drag = QDrag(self)
     mim_data = QMimeData()
     mim_data.setText(text)
     drag.setMimeData(mim_data)
     dropAction = drag.exec_(Qt.MoveAction)
开发者ID:Meller008,项目名称:CRM-Avi,代码行数:14,代码来源:table_widget_dad.py

示例7: mousePressEvent

    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,代码行数:32,代码来源:draggableicons.py

示例8: mouseMoveEvent

    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,代码行数:49,代码来源:glyphCollectionView.py

示例9: maybeExecuteDrag

    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,代码行数:15,代码来源:glyphCellView.py

示例10: mouseMoveEvent

 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,代码行数:15,代码来源:qtwrapper.py

示例11: mouseMoveEvent

 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,代码行数:27,代码来源:Tabview.py

示例12: mouseMoveEvent

 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", "tab-reordering")
         mimeData.setData("tabbar-id", str(id(self)))
         drag.setMimeData(mimeData)
         drag.exec_()
     E5WheelTabBar.mouseMoveEvent(self, event)
开发者ID:Darriall,项目名称:eric,代码行数:18,代码来源:E5TabWidget.py

示例13: startDrag

    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,代码行数:8,代码来源:delayedencoding.py

示例14: mouseMoveEvent

 def mouseMoveEvent(self, evt):
     """
     Protected method to handle mouse move events.
     
     @param evt reference to the event (QMouseEvent)
     """
     if self.__model is None:
         super(E5ModelMenu, self).mouseMoveEvent(evt)
         return
     
     if not (evt.buttons() & Qt.LeftButton):
         super(E5ModelMenu, self).mouseMoveEvent(evt)
         return
     
     manhattanLength = (evt.pos() -
                        self.__dragStartPosition).manhattanLength()
     if manhattanLength <= QApplication.startDragDistance():
         super(E5ModelMenu, self).mouseMoveEvent(evt)
         return
     
     act = self.actionAt(self.__dragStartPosition)
     if act is None:
         super(E5ModelMenu, self).mouseMoveEvent(evt)
         return
     
     idx = self.index(act)
     if not idx.isValid():
         super(E5ModelMenu, self).mouseMoveEvent(evt)
         return
     
     drag = QDrag(self)
     drag.setMimeData(self.__model.mimeData([idx]))
     actionRect = self.actionGeometry(act)
     if qVersion() >= "5.0.0":
         drag.setPixmap(self.grab(actionRect))
     else:
         drag.setPixmap(QPixmap.grabWidget(self, actionRect))
     
     if drag.exec_() == Qt.MoveAction:
         row = idx.row()
         if self.__dropIndex == idx.parent() and self.__dropRow <= row:
             row += 1
         self.__model.removeRow(row, self.__root)
         
         if not self.isAncestorOf(drag.target()):
             self.close()
         else:
             self.aboutToShow.emit()
开发者ID:testmana2,项目名称:test,代码行数:48,代码来源:E5ModelMenu.py

示例15: startDrag

 def startDrag(self, mainwin, ev):
     d = mainwin.currentDocument()
     if not d:
         return
     url = d.url()
     if url.isEmpty():
         return
     drag = QDrag(mainwin)
     data = QMimeData()
     data.setUrls([url])
     drag.setMimeData(data)
     pixmap = mainwin.style().standardPixmap(QStyle.SP_FileIcon, 0, mainwin)
     hotspot = QPoint(pixmap.width() - 5, 5)
     drag.setPixmap(pixmap)
     drag.setHotSpot(hotspot)
     drag.start(Qt.LinkAction | Qt.CopyAction)
开发者ID:19joho66,项目名称:frescobaldi,代码行数:16,代码来源:icon_drag_eventhandler.py


注:本文中的PyQt5.QtGui.QDrag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。