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


Python QtCore.QMimeData类代码示例

本文整理汇总了Python中PyQt5.QtCore.QMimeData的典型用法代码示例。如果您正苦于以下问题:Python QMimeData类的具体用法?Python QMimeData怎么用?Python QMimeData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QMimeData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mousePressEvent

    def mousePressEvent(self, event):
        child = self.childAt(event.pos())
        if not child:
            return

        pixmap = QPixmap(child.pixmap())

        itemData = QByteArray()
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)
        dataStream << pixmap << QPoint(event.pos() - child.pos())

        mimeData = QMimeData()
        mimeData.setData('application/x-dnditemdata', itemData)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos() - child.pos())

        tempPixmap = QPixmap(pixmap)
        painter = QPainter()
        painter.begin(tempPixmap)
        painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127))
        painter.end()

        child.setPixmap(tempPixmap)

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            child.close()
        else:
            child.show()
            child.setPixmap(pixmap)
开发者ID:Axel-Erfurt,项目名称:pyqt5,代码行数:32,代码来源:draggableicons.py

示例2: test_pasteImage_RestructuredText

	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,代码行数:7,代码来源:test_editor.py

示例3: testMove

    def testMove(self):
        w = self.newWidget()
        item = w._path_item_map.get("/Variables/u")
        #b = w.tree.getBlockInfo("/Variables/u")
        w.scrollToItem(item)
        point = w.visualItemRect(item).center()
        item1 = w._path_item_map.get("/Variables/v")
        #b1 = w.tree.getBlockInfo("/Variables/v")
        w.scrollToItem(item1)
        point1 = w.visualItemRect(item1).bottomLeft()

        #idx = b.parent.children_list.index(b.name)
        #idx1 = b.parent.children_list.index(b1.name)
        w.setCurrentItem(item)
        mime = QMimeData()
        mime.setData(w._mime_type, "some data")
        ee = QDragEnterEvent(w.mapToGlobal(point), Qt.MoveAction, mime, Qt.LeftButton, Qt.NoModifier)
        w.dragEnterEvent(ee)
        #Testing.process_events(t=1)
        de = QDropEvent(w.mapToGlobal(point1), Qt.MoveAction, mime, Qt.LeftButton, Qt.NoModifier)
        w.dropEvent(de)
        # This doesn't seem to work for some reason
        #self.assertEqual(idx1, b.parent.children_list.index(b.name))
        #self.assertEqual(idx, b.parent.children_list.index(b1.name))

        w.setCurrentItem(None)
        self.assertEqual(w._current_drag, None)
        w.dropEvent(de)

        w.dragEnterEvent(ee)
        self.assertEqual(w._current_drag, None)
        w.setCurrentItem(item1)
        w.dragEnterEvent(ee)
        self.assertNotEqual(w._current_drag, None)
        w.dropEvent(de)
开发者ID:FHilty,项目名称:moose,代码行数:35,代码来源:test_BlockTree.py

示例4: mousePressEvent

 def mousePressEvent(self, event):
     mime = QMimeData()
     itemData = QByteArray()
     mime.setData('application/x-dnditemdata', itemData)
     drag = QDrag(self)
     drag.setMimeData(mime)
     drag.exec_(Qt.MoveAction)
开发者ID:thesmartwon,项目名称:OpenChess-Python,代码行数:7,代码来源:tests.py

示例5: mouseMoveEvent

    def mouseMoveEvent(self, event):
        """ If the mouse moves far enough when the left mouse button is held
            down, start a drag and drop operation.
        """
        if not event.buttons() & Qt.LeftButton:
            return

        if (event.pos() - self.dragStartPosition).manhattanLength() \
             < QApplication.startDragDistance():
            return

        if not self.hasImage:
            return

        drag = QDrag(self)
        mimeData = QMimeData()

        output = QByteArray()
        outputBuffer = QBuffer(output)
        outputBuffer.open(QIODevice.WriteOnly)
        self.imageLabel.pixmap().toImage().save(outputBuffer, 'PNG')
        outputBuffer.close()
        mimeData.setData('image/png', output)

        drag.setMimeData(mimeData)
        drag.setPixmap(self.imageLabel.pixmap().scaled(64, 64, Qt.KeepAspectRatio))
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                                      drag.pixmap().height()))
        drag.start()
开发者ID:death-finger,项目名称:Scripts,代码行数:29,代码来源:separations.py

示例6: test_pasteImage_Markdown

	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,代码行数:7,代码来源:test_editor.py

示例7: mimeData

 def mimeData(self, indexes):
     """
     Public method to return the mime data.
     
     @param indexes list of indexes (QModelIndexList)
     @return mime data (QMimeData)
     """
     from .XbelWriter import XbelWriter
     
     data = QByteArray()
     stream = QDataStream(data, QIODevice.WriteOnly)
     urls = []
     
     for index in indexes:
         if index.column() != 0 or not index.isValid():
             continue
         
         encodedData = QByteArray()
         buffer = QBuffer(encodedData)
         buffer.open(QIODevice.ReadWrite)
         writer = XbelWriter()
         parentNode = self.node(index)
         writer.write(buffer, parentNode)
         stream << encodedData
         urls.append(index.data(self.UrlRole))
     
     mdata = QMimeData()
     mdata.setData(self.MIMETYPE, data)
     mdata.setUrls(urls)
     return mdata
开发者ID:testmana2,项目名称:test,代码行数:30,代码来源:BookmarksModel.py

示例8: copy

 def copy(self):
     """Copy to the clipboard"""
     data = QMimeData()
     text = '\n'.join([cursor.selectedText() \
                         for cursor in self.cursors()])
     data.setText(text)
     data.setData(self.MIME_TYPE, text.encode('utf8'))
     QApplication.clipboard().setMimeData(data)
开发者ID:Aldenis2112,项目名称:qutepart,代码行数:8,代码来源:rectangularselection.py

示例9: mimeData

    def mimeData(self, indexes):
        """See QAbstractItemModel documentation"""
        if len(indexes) != 1:
            return 0

        data = QMimeData()
        data.setData(self.mimeTypes()[0], QByteArray.number(indexes[0].row()))
        return data
开发者ID:rapgro,项目名称:enki,代码行数:8,代码来源:openedfilemodel.py

示例10: mimeData

	def mimeData(self, index_list):
		data = QMimeData()
		g_list = []
		for idx in index_list:
			g = idx.data(GalleryModel.GALLERY_ROLE)
			if g != None:
				g_list.append(g)
		data.setData("list/gallery", QByteArray(pickle.dumps(g_list)))
		return data
开发者ID:ImoutoChan,项目名称:happypanda,代码行数:9,代码来源:gallery.py

示例11: copy_image

def copy_image():
    img = QImage()
    img.loadFromData(f.read())

    data = QMimeData()
    data.setImageData(img)

    clipboard.setMimeData(data)
    print("ok")
开发者ID:piec,项目名称:dotfiles,代码行数:9,代码来源:clip-qt5.py

示例12: dragFile

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)
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:10,代码来源:drag.py

示例13: mimeData

    def mimeData(self, indexes):
        mimeData = QMimeData()
        encodedData = QByteArray()
        stream = QDataStream(encodedData, QIODevice.WriteOnly)
        for index in indexes:
            if (index.isValid()):
                stream.writeInt(self.tileIndexAt(index))

        mimeData.setData(TILES_MIMETYPE, encodedData)
        return mimeData
开发者ID:theall,项目名称:Python-Tiled,代码行数:10,代码来源:tilesetmodel.py

示例14: copyOutlines

 def copyOutlines(self):
     glyph = self.view.glyph()
     clipboard = QApplication.clipboard()
     mimeData = QMimeData()
     copyGlyph = glyph.getRepresentation("defconQt.FilterSelection")
     mimeData.setData("application/x-defconQt-glyph-data",
                      pickle.dumps([copyGlyph.serialize(
                          blacklist=("name", "unicode")
                      )]))
     clipboard.setMimeData(mimeData)
开发者ID:bitforks,项目名称:trufont,代码行数:10,代码来源:glyphView.py

示例15: __dragSnapshot

 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,代码行数:10,代码来源:SnapWidget.py


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