本文整理汇总了Python中PyQt4.QtCore.QMimeData.setImageData方法的典型用法代码示例。如果您正苦于以下问题:Python QMimeData.setImageData方法的具体用法?Python QMimeData.setImageData怎么用?Python QMimeData.setImageData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QMimeData
的用法示例。
在下文中一共展示了QMimeData.setImageData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startDrag
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setImageData [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)
示例2: startDrag
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setImageData [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)
示例3: _drag_image
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setImageData [as 别名]
def _drag_image ( self, image ):
mime_data = QMimeData()
mime_data.setImageData( QVariant( image ) )
return mime_data