本文整理汇总了Python中PyQt5.QtCore.QMimeData.setImageData方法的典型用法代码示例。如果您正苦于以下问题:Python QMimeData.setImageData方法的具体用法?Python QMimeData.setImageData怎么用?Python QMimeData.setImageData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QMimeData
的用法示例。
在下文中一共展示了QMimeData.setImageData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pasteImage_RestructuredText
# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setImageData [as 别名]
def test_pasteImage_RestructuredText(self, _mock_image, _mock_editor):
mimeData = QMimeData()
mimeData.setImageData(self._create_image())
self.dummytab.markupClass = ReStructuredTextMarkup
self.editor.insertFromMimeData(mimeData)
self.assertTrue('.. image:: myimage.jpg' in self.editor.toPlainText())
示例2: mouseMoveEvent
# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setImageData [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)
示例3: test_pasteImage_Markdown
# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setImageData [as 别名]
def test_pasteImage_Markdown(self, _mock_image, _mock_editor):
mimeData = QMimeData()
mimeData.setImageData(self._create_image())
self.dummytab.markupClass = MarkdownMarkup
self.editor.insertFromMimeData(mimeData)
self.assertTrue('![myimage](myimage.jpg)' in self.editor.toPlainText())
示例4: copy_image
# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setImageData [as 别名]
def copy_image():
img = QImage()
img.loadFromData(f.read())
data = QMimeData()
data.setImageData(img)
clipboard.setMimeData(data)
print("ok")
示例5: __dragSnapshot
# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setImageData [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)
示例6: startDrag
# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.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)
示例7: test_allowImageOnClipboard
# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setImageData [as 别名]
def test_allowImageOnClipboard(self):
mimeData = QMimeData()
mimeData.setImageData(self._create_image())
self.assertTrue(self.editor.canInsertFromMimeData(mimeData))