def foo(self): fmt = QTextCharFormat() fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType) cursor = self.textEdit.textCursor() cursor.insertText(py3k.unichr(0xfffc), fmt) self.textEdit.setTextCursor(cursor) self.textEdit.close()
def generatePlotFormat(plot, width, height): picture = QPicture() qcpPainter = QCPPainter() qcpPainter.begin(picture) plot.toPainter(qcpPainter, width, height) qcpPainter.end() result = QTextCharFormat() result.setObjectType(MainWindow.QCPTextFormat) result.setProperty(MainWindow.QCPData, picture) return result