def createMimeDataFromSelection( fragment: QTextDocumentFragment) -> QMimeData: mime = QMimeData() mime.setText(fragment.toPlainText()) mime.setHtml(fragment.toHtml(b"utf-8")) # missing here is odf return mime
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)
def test_script_insert_mime_text(self): current = self.widget.text.toPlainText() insert = "test\n" cursor = self.widget.text.cursor() cursor.setPos(0, 0) mime = QMimeData() mime.setText(insert) self.widget.text.insertFromMimeData(mime) self.assertEqual(insert + current, self.widget.text.toPlainText())
def test_script_insert_mime_text(self): current = self.widget.text.toPlainText() insert = "test\n" cursor = self.widget.text.cursor() cursor.setPos(0, 0) mime = QMimeData() mime.setText(insert) self.widget.text.insertFromMimeData(mime) self.assertEqual(insert + current, self.widget.text.toPlainText())
def copyLinkLocation(): mime = QMimeData() mime.setText(link) QApplication.clipboard().setMimeData(mime)