Why QAbstractTextDocumentLayout::documentChanged::from == -1?

152 views Asked by At

I am trying to force capitalisation in QTextEdit (QTextCharBlockFormat is in the past, already tried) by replacing non-capital blocks inside QTextEdit::contentsChange signal processing. Here, I have some conditional block, which replaces the entire block:

QTextCursor cur = textCursor();
cur.setPosition(block.position(), QTextCursor::MoveAnchor);
cur.setPosition(block.position() + capital_val.size(), QTextCursor::KeepAnchor);
cur.insertText(capital_val);

And then, in my custom QAbstractTextDocumentLayout::documentChanged I recieve 1st parameter == -1. Why? It should be equal to block.position().

1

There are 1 answers

0
ultrablox On

It is because all the document editing initiated from ::contentsChange must be deferred and executed from ::textChanged.