I want to change format of some blocks within a QTextDocument without effecting undo stack, How can I do this?

"setUndoRedoEnabled(false)" doesn't work for my purpose, because it clears undo stack!
Is subclassing "QAbstractTextDocumentLayout" the solution?