

insertFromMimeData handles the actual adding of the mime content to the document.If you return False a cannot-drop indicator will be shown. Icon with a plus-sign or a drop animation.

If this method returns True the window manager will usually show an accept-drop indicator, e.g. This method should return True if you can accept the data being provided. canInsertFromMimeData is a check which confirms whether a particular type can be accepted by.Similar mechanisms are used for other widget types. Parameter source which receives a QMimeData object. images, or other objects) dropped onto your editor. The two handlers canInsertFromMimeData and insertFromMimeData are Qt's methods for accepting Super(TextEdit, self).insertFromMimeData(source)

# If we hit a non-image or non-local URL break the loop and fall outĭocument.addResource(QTextDocument.ImageResource, uuid, image) If u.isLocalFile() and file_ext in IMAGE_EXTENSIONS:ĭocument.addResource(QTextDocument.ImageResource, u, image) Return super(TextEdit, self).canInsertFromMimeData(source)įile_ext = splitext(str(u.toLocalFile()))
