I would like to delete the selected text inside a QGraphicsTextItem
.
I have been searching all the classes it uses - like QTextCursor
, QTextDocument
... I can't find anything to remove text, except the clear()
function of the QTextDocument
which removes everything...
How can I remove the selection ?
QTextCursor _cursor = textCursor();
if(_cursor.hasSelection())
?
Alternatively (since I need this for a custom paste command), how can I replace the selection with an existing text or html ?
QClipboard* _clipboard = QApplication::clipboard();
const QMimeData* _mimeData = _clipboard->mimeData();
if (_mimeData->hasHtml())
{
QTextCursor _cursor = textCursor();
if(_cursor.hasSelection())
?
_cursor.insertHtml(_mimeData->html());
}