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


Python QDrag.setPixmap方法代码示例

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


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

示例1: __onDragStarted

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
    def __onDragStarted(self, index):
        desc = index.data(QtWidgetRegistry.WIDGET_DESC_ROLE)
        icon = index.data(Qt.DecorationRole)

        drag_data = QMimeData()
        drag_data.setData(
            "application/vnv.orange-canvas.registry.qualified-name",
            desc.qualified_name
        )
        drag = QDrag(self)
        drag.setPixmap(icon.pixmap(38))
        drag.setMimeData(drag_data)

        # TODO: Should animate (accept) hide.
        self.hide()

        # When a drag is started and the menu hidden the item's tool tip
        # can still show for a short time UNDER the cursor preventing a
        # drop.
        viewport = self.__menu.view().viewport()
        filter = ToolTipEventFilter()
        viewport.installEventFilter(filter)

        drag.exec_(Qt.CopyAction)

        viewport.removeEventFilter(filter)
开发者ID:CHANAYA,项目名称:orange3,代码行数:28,代码来源:canvastooldock.py

示例2: mousePressEvent

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
	def mousePressEvent( self, event ):
		# handle an internal move
		from PyQt4.QtCore import Qt

		# start a drag event
		if ( event.button() == Qt.LeftButton and self.dragDropRect().contains( event.pos() ) ):
			from PyQt4.QtCore import QMimeData
			from PyQt4.QtGui import QDrag, QPixmap

			# create the pixmap
			pixmap = QPixmap.grabWidget( self, self.rect() )

			# create the mimedata
			mimeData = QMimeData()
			mimeData.setText( 'ItemTitle::%s' % (self.title()) )

			# create the drag
			drag = QDrag(self)
			drag.setMimeData( mimeData )
			drag.setPixmap( pixmap )
			drag.setHotSpot( event.pos() )

			if ( not drag.exec_() ):
				self._accordianWidget.emitItemDragFailed(self)

			event.accept()

		# determine if the expand/collapse should occur
		elif ( event.button() == Qt.LeftButton and self.expandCollapseRect().contains( event.pos() ) ):
			self._clicked = True
			event.accept()

		else:
			event.ignore()
开发者ID:skarone,项目名称:PipeL,代码行数:36,代码来源:collapsable_groupbox.py

示例3: eventFilter

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
 def eventFilter( self, object, event ):
     if event.type() == event.MouseButtonPress:
         if self.isLocked():
             return False
             
         if event.button() == Qt.MidButton or \
            (event.button() == Qt.LeftButton and \
             event.modifiers() == Qt.ShiftModifier):
             index = self.tabBar().tabAt(event.pos())
             view  = self.widget(index)
             pixmap = QPixmap.grabWidget(view)
             drag = QDrag(self)
             data = QMimeData()
             data.setText('move view:{}'.format(index))
             drag.setMimeData(data)
             drag.setPixmap(pixmap)
             drag.exec_()
             
             return True
         return False
         
     elif event.type() == event.DragEnter:
         if ( str(event.mimeData().text()).startswith('move view:') and
              event.source() != self ):
             event.acceptProposedAction()
         return True
     
     elif event.type() == event.Drop:
         text = str(event.mimeData().text())
         splt = text.split(':')
         self.snagViewFromPanel(event.source(), int(splt[1]))
         return True
     
     return False
开发者ID:satishgoda,项目名称:DPS_PIPELINE,代码行数:36,代码来源:xviewpanel.py

示例4: dragFile

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [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:EdwardBetts,项目名称:frescobaldi,代码行数:12,代码来源:drag.py

示例5: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
 def startDrag(self,event):
     drag = QDrag(event.widget())
     drag.setPixmap(self.mute.icon().pixmap(self.size().height(),self.size().height()))
     mimedata = QMimeData()
     liste = []
     liste.append(QUrl( "veromix://sink_index:"+str(int(self.index)) ))
     mimedata.setUrls(liste)
     drag.setMimeData(mimedata)
     #drag.setHotSpot(event.pos() - self.rect().topLeft())
     dropAction = drag.start(Qt.MoveAction)
开发者ID:florianjacob,项目名称:veromix-plasmoid,代码行数:12,代码来源:SinkUI.py

示例6: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [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)
     pixmap = QPixmap.fromImage(image)
     drag.setPixmap(pixmap)
     drag.setHotSpot(pixmap.rect().center())
     drag.exec_(Qt.CopyAction)
开发者ID:WedgeLeft,项目名称:frescobaldi,代码行数:14,代码来源:imageviewer.py

示例7: __startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
 def __startDrag(self, button):
     """
     Start a drag from button
     """
     action = button.defaultAction()
     desc = action.data()  # Widget Description
     icon = action.icon()
     drag_data = QMimeData()
     drag_data.setData("application/vnv.orange-canvas.registry.qualified-name", desc.qualified_name.encode("utf-8"))
     drag = QDrag(button)
     drag.setPixmap(icon.pixmap(self.iconSize()))
     drag.setMimeData(drag_data)
     drag.exec_(Qt.CopyAction)
开发者ID:BlazZupan,项目名称:orange3,代码行数:15,代码来源:widgettoolbox.py

示例8: drag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
 def drag(self, tile=None, meld=None):
     """returns a drag object"""
     drag = QDrag(self)
     mimeData = MimeData(tile, meld)
     drag.setMimeData(mimeData)
     tile = tile or meld[0]
     graphics = tile.graphics
     tRect = graphics.boundingRect()
     tRect = self.viewportTransform().mapRect(tRect)
     pmapSize = QSize(tRect.width() * graphics.scale(), tRect.height() * graphics.scale())
     pMap = graphics.pixmapFromSvg(pmapSize)
     drag.setPixmap(pMap)
     drag.setHotSpot(QPoint(pMap.width()/2, pMap.height()/2))
     return drag
开发者ID:jsj2008,项目名称:kdegames,代码行数:16,代码来源:board.py

示例9: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
 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:arnaldorusso,项目名称:frescobaldi,代码行数:18,代码来源:icon_drag_eventhandler.py

示例10: start_drag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
    def start_drag(self, info_id):
        _logger.info( "started dragging" )
        mimeData = QMimeData()
        mimeData.data =("/" + info_id.partition("/")[2].partition("/")[0], moose.element(info_id))
        mimeData.setText(info_id)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        pixmap = QPixmap("")

        drag.setPixmap(pixmap)
        # drag.setHotSpot(e.pos() - self.rect().topLeft())
        dropAction = drag.start(QtCore.Qt.MoveAction)
        print((" => ", dropAction))
        self.select_info.set_event_type(0)
        self._timer.start(0)
        return
开发者ID:dilawar,项目名称:moose-gui,代码行数:18,代码来源:NeuroKitVisualizer.py

示例11: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
 def startDrag(self, event):
     index = self.indexAt(event.pos())
     if not index.isValid():
         return
     drag = QDrag(self)
     mimeData = QtCore.QMimeData()
     el = self.model().listdata[index.row()]
     print("dragging device with id: " + str(el['deviceid']))
     mimeData.setData("application/x-xinputdevice", pickle.dumps(el))
     drag.setMimeData(mimeData)
     pixmap = QtGui.QPixmap()
     pixmap = pixmap.grabWidget(self, self.rectForIndex(index))
     drag.setPixmap(pixmap)
     #drag.setHotSpot(QtCore.QPoint(pixmap.width()/2, pixmap.height()/2))
     result = drag.start(QtCore.Qt.MoveAction)
     if result == 1:
         self.model().listdata.remove(el)
开发者ID:ChristophHaag,项目名称:mpxgui,代码行数:19,代码来源:mpxgui.py

示例12: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [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:uliska,项目名称:frescobaldi,代码行数:19,代码来源:imageviewer.py

示例13: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
    def startDrag(self, supportedActions):
        """ Overwritten function of QTreeWidget.

        This function creates a QDrag object representing the selected element of this TreeWidget.
        """
        logging.debug(self.__class__.__name__ +": startDrag()")
        indexes = self.selectedIndexes()
        if len(indexes) > 0:
            data = self.model().mimeData(indexes)
            if not data:
                return
            drag = QDrag(self)
            drag.setMimeData(data)
            if self.model().data(indexes[0], Qt.DecorationRole).type() == QVariant.Icon:
                icon = QIcon(self.model().data(indexes[0], Qt.DecorationRole))
                drag.setPixmap(icon.pixmap(QSize(50, 50)))
                drag.setHotSpot(QPoint(drag.pixmap().width()/2, drag.pixmap().height()/2))  # center icon in respect to cursor
            defaultDropAction = Qt.IgnoreAction
            drag.exec_(supportedActions, defaultDropAction)
开发者ID:Moanwar,项目名称:cmssw,代码行数:21,代码来源:SimpleDraggableTreeWidget.py

示例14: start_drag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
    def start_drag(self, info_id):
        # pixmap = QPixmap()
        # painter = QPainter( pixmap )
        # painter.setFont( QFont("Arial") );
        # painter.drawText( QPoint(100, 100), info_id );
        mimeData = QMimeData()
        mimeData.data =("/" + info_id.partition("/")[2].partition("/")[0], moose.element(info_id))
        mimeData.setText(info_id)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        pixmap = QPixmap("")

        drag.setPixmap(pixmap)
        # drag.setHotSpot(e.pos() - self.rect().topLeft())
        dropAction = drag.start(QtCore.Qt.MoveAction)
        print(" => ", dropAction)
        self.select_info.set_event_type(0)
        self._timer.start(0)
        return
开发者ID:NeuroArchive,项目名称:moose,代码行数:21,代码来源:NeuroKitVisualizer.py

示例15: mouseMoveEvent

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setPixmap [as 别名]
    def mouseMoveEvent(self, e):
        if self.drag_start is None:
            pass
        x = e.x() - self.drag_start.x()
        y = e.y() - self.drag_start.y()
        dist = QApplication.startDragDistance()
        if not self.draggable or x > dist or y > dist:
            return

        drag = QDrag(self)
        mime = QMimeData()
        mime.setText(self.__class__.__name__)
        mime.part = self
        drag.setMimeData(mime)
        pixmap = QPixmap.grabWidget(self)
        pixmap.setAlphaChannel(pixmap)
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                               drag.pixmap().height()))
        drag.start(Qt.CopyAction)
开发者ID:patrickkidd,项目名称:pksampler,代码行数:22,代码来源:parts.py


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