I think this is a very simple question, but when I copy an image I can’t paste it in a QTextEdit? Paste is inactive! Also I would like to know how to drag-and-drop a picture.
BTW I use the following code in order to insert a picture into a QTextEdit:
QTextEdit *textEditor = new QTextEdit(0);
QTextDocumentFragment fragment;
fragment = QTextDocumentFragment::fromHtml("<img src='C:\\aaa.jpg'>");
textEditor->textCursor().insertFragment(fragment);
textEditor->setVisible(true);
Is it recommended? How do you do this operation?
The second way is this:
The third way is to inherit QTextEdit and reimplement
canInsertFromMimeDataandinsertFromMimeDatafunctions as follows. By the way this method allows to use drag-and-drop or copy-paste mechanisms.Just wanted to share what I have found during long investigation :).