I introduced a certain custom key shortcut to allow deleting of next 10 characters in a QLineEdit, beginning at the current text cursor position. But I want to have this undoable. Unfortunately QLineEdit does not provide QTextDocument or QTextCursor objects so I tried the following code:
int pos = lineEdit->cursorPosition();
lineEdit->setSelection(pos, pos + 10);
lineEdit->del();
This works fine but when I press undo (Ctrl+Z) the deleted text is back (which is what I want) but it is selected (which is what I do not want, instead I want to return to state before I programatically selected the text). I would prefer to have the option to wrap the selection and deletion into one 'macro' undo step. Is this possible? Something like https://doc.qt.io/qt-5/qtextcursor.html#beginEditBlock ?