def insertTextObject(self):
fileName = self.fileNameLineEdit.text()
file = QFile(fileName)
if not file.open(QIODevice.ReadOnly):
QMessageBox.warning(self, "Error Opening File",
"Could not open '%s'" % fileName)
svgData = file.readAll()
svgCharFormat = QTextCharFormat()
svgCharFormat.setObjectType(Window.SvgTextFormat)
svgCharFormat.setProperty(Window.SvgData, svgData)
try:
# Python v2.
orc = unichr(0xfffc)
except NameError:
# Python v3.
orc = chr(0xfffc)
cursor = self.textEdit.textCursor()
cursor.insertText(orc, svgCharFormat)
self.textEdit.setTextCursor(cursor)
评论列表
文章目录