本文整理汇总了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)
示例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()
示例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
示例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)
示例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)
示例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)
示例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)
示例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
示例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)
示例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
示例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)
示例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)
示例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)
示例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
示例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)