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


Python QMimeData.setImageData方法代码示例

本文整理汇总了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())
开发者ID:liyongming1982,项目名称:retext,代码行数:9,代码来源:test_editor.py

示例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)
开发者ID:CarlosAndres12,项目名称:pyqt5,代码行数:36,代码来源:dragdroprobot.py

示例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())
开发者ID:liyongming1982,项目名称:retext,代码行数:9,代码来源:test_editor.py

示例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")
开发者ID:piec,项目名称:dotfiles,代码行数:11,代码来源:clip-qt5.py

示例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)
开发者ID:pycom,项目名称:EricShort,代码行数:12,代码来源:SnapWidget.py

示例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)
开发者ID:19joho66,项目名称:frescobaldi,代码行数:19,代码来源:imageviewer.py

示例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))
开发者ID:liyongming1982,项目名称:retext,代码行数:6,代码来源:test_editor.py


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