def _insert_img(self, cursor, img, fmt):
try:<EOL><INDENT>image = QtGui.QImage()<EOL>image.loadFromData(img, fmt.upper())<EOL><DEDENT>except ValueError:<EOL><INDENT>self._insert_plain_text(cursor, '<STR_LIT>'%fmt)<EOL><DEDENT>else:<EOL><INDENT>format = self._add_image(image)<EOL>cursor.insertBlock()<EOL>cursor.insertImage(format)<EOL>cursor.insertBlock()<EOL><DEDENT>
insert a raw image, jpg or png