def insertTextObject(self, obj):
svgData = b'<svg...></svg>'
svgCharFormat = QTextCharFormat()
svgCharFormat.setObjectType(MainWindow.SvgTextFormat)
svgCharFormat.setProperty(MainWindow.SvgData, svgData)
orc = chr(0xfffc)
cursor = obj.textCursor()
cursor.insertText(orc, svgCharFormat)
obj.setTextCursor(cursor)
以上代码可以插入一个SVG图片到textEdit中,但我如果想判断是哪一个SVG图片,该怎么做呢?
比如:
self.insertTextObject(obj) #插入svg
textCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor) #选择插入的svg
svg = textCursor.selectedText()
if svg == ?: #这里应该怎么做呢?
pass
我记得文档里面说了,有个槽里面的方法获取index项这个方法