本文整理汇总了Python中PyQt5.Qt.QMimeData.setImageData方法的典型用法代码示例。如果您正苦于以下问题:Python QMimeData.setImageData方法的具体用法?Python QMimeData.setImageData怎么用?Python QMimeData.setImageData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QMimeData
的用法示例。
在下文中一共展示了QMimeData.setImageData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mousePressEvent
# 需要导入模块: from PyQt5.Qt import QMimeData [as 别名]
# 或者: from PyQt5.Qt.QMimeData import setImageData [as 别名]
def mousePressEvent(self, event):
self.parentWidget().mousePressEvent(event)
if not self.parentWidget().isDraging():
super(WebView, self).mousePressEvent(event)
if event.buttons() == Qt.LeftButton:
mimeData = QMimeData()
hitTestResult = self.mainFrame.hitTestContent(event.pos())
# print(hitTestResult.linkUrl())
# dragging the scrollbar
if hitTestResult.isNull():
self.draging = True
if hitTestResult.isContentSelected():
mimeData.setText(self.selectedText())
mimeData.setHtml(self.selectedHtml())
elif not hitTestResult.linkUrl().isEmpty():
mimeData.setUrls([hitTestResult.linkUrl()])
mimeData.setHtml(hitTestResult.element().toOuterXml())
elif not hitTestResult.pixmap().isNull():
mimeData.setImageData(hitTestResult.pixmap())
mimeData.setUrls([hitTestResult.imageUrl()])
mimeData.setHtml(hitTestResult.element().toOuterXml())
# mimeData.setData('application/x-qt-windows-mime;value="FileContents"', QVariant(hitTestResult.pixmap()).toByteArray())
# elif not hitTestResult.mediaUrl().isEmpty():
# mimeData.setUrls([hitTestResult.mediaUrl()])
# mimeData.setHtml(hitTestResult.element().toOuterXml())
else:
return
# pixmap = hitTestResult.pixmap()
# pixmap.setMask(QBitmap.fromImage(pixmap.toImage()))
self.drag.setMimeData(mimeData)
示例2: copy_metadata
# 需要导入模块: from PyQt5.Qt import QMimeData [as 别名]
# 或者: from PyQt5.Qt.QMimeData import setImageData [as 别名]
def copy_metadata(self):
rows = self.gui.library_view.selectionModel().selectedRows()
if not rows or len(rows) == 0:
return error_dialog(self.gui, _('Cannot copy metadata'),
_('No books selected'), show=True)
if len(rows) > 1:
return error_dialog(self.gui, _('Cannot copy metadata'),
_('Multiple books selected, can only copy from one book at a time.'), show=True)
db = self.gui.current_db
book_id = db.id(rows[0].row())
mi = db.new_api.get_metadata(book_id)
md = QMimeData()
md.setText(unicode(mi))
md.setData('application/calibre-book-metadata', bytearray(metadata_to_opf(mi, default_lang='und')))
img = db.new_api.cover(book_id, as_image=True)
if img:
md.setImageData(img)
c = QApplication.clipboard()
c.setMimeData(md)